Skip to content

Instantly share code, notes, and snippets.

@fauxsaurus
Created February 16, 2026 19:30
Show Gist options
  • Select an option

  • Save fauxsaurus/a1b454db4c30e3fbc095b05d1afe70ea to your computer and use it in GitHub Desktop.

Select an option

Save fauxsaurus/a1b454db4c30e3fbc095b05d1afe70ea to your computer and use it in GitHub Desktop.
Quickly convert TSV strings to JSON (note: does NOT support escaped tabs).
const tsv2json = (tsv: string) => {
const [cols, ...rows] = tsv.split('\n').map(line => line.split('\t'))
return rows.map(row =>
Object.fromEntries(row.map((cell, i) => [cols[i], cell])),
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment