SmartQueryTools

Convert TSV to JSON Online

Convert TSV files to JSON format directly in your browser. No upload required — your data never leaves your device.

About converting TSV to JSON

TSV to JSON comes up when tab-delimited output has to feed code or a web front end. A common case is scientific data behind a visualisation, such as gene annotations or sample metadata loaded by a D3 or Observable chart, or a lookup table baked into a static site. Another is the TSV download offered by tools like Google Sheets, when a developer wants records with named fields.

Each TSV row becomes an object in one JSON array, keyed by the header line. Values that contain commas or apostrophes need no special handling. They arrive as ordinary JSON strings, and only double quotes and backslashes get JSON escapes.

Headerless TSVs are the pitfall. Many bioinformatics formats, including BED and BLAST tabular output, have no header row, so the keys come out as column0, column1 and so on. Add a header line first if you want keys like chrom and start. Also check what counts as missing. R's NA or a database \N comes out as the string "NA" or "\N", not null, and it turns the rest of that column into strings as well. Replace those markers with empty fields to get null.

Worked example

A small sample file, converted with the default settings.

Input (TSV)

symbol	chrom	description	tpm	detected
TP53	chr17	tumor protein p53	24.7	true
BRCA1	chr17	BRCA1 DNA repair associated	8.13	true
NT5C	chr17	5', 3'-nucleotidase, cytosolic	3.4	true
SREBF2	chr22	sterol regulatory element binding transcription factor 2		false

Output (JSON)

[
  {
    "symbol": "TP53",
    "chrom": "chr17",
    "description": "tumor protein p53",
    "tpm": 24.7,
    "detected": true
  },
  {
    "symbol": "BRCA1",
    "chrom": "chr17",
    "description": "BRCA1 DNA repair associated",
    "tpm": 8.13,
    "detected": true
  },
  {
    "symbol": "NT5C",
    "chrom": "chr17",
    "description": "5', 3'-nucleotidase, cytosolic",
    "tpm": 3.4,
    "detected": true
  },
  {
    "symbol": "SREBF2",
    "chrom": "chr22",
    "description": "sterol regulatory element binding transcription factor 2",
    "tpm": null,
    "detected": false
  }
]

What changes when you convert TSV to JSON

  • Each TSV row becomes one object in a top-level array. Keys come from the header line, in the same order.
  • NT5C's description is a normal JSON string. Its commas and apostrophes need no escaping.
  • tpm values are JSON numbers (24.7, 8.13), and detected is true or false.
  • SREBF2's missing tpm is written as null.
  • A file without a header row gets the keys column0, column1, column2 and so on.

Your file is processed locally in your browser and is never uploaded. The free limit is 50 MB per file; larger files work if your device has the memory for them.

Frequently Asked Questions

How do I load the JSON in D3 or Observable?

d3.json("genes.json") or FileAttachment("genes.json").json() returns the array with numbers and booleans already typed. d3.tsv, by contrast, reads every value as a string unless you pass d3.autoType.

Why are my keys column0, column1 instead of names?

The file has no header line, which is normal for formats such as BED and BLAST -outfmt 6. Add a line with the column names at the top of the TSV and convert again.

Can I get an object keyed by gene symbol instead of an array?

The converter always writes an array. Reshape it afterwards with jq, for example jq 'map({(.symbol): .}) | add' genes.json, which returns one object keyed by symbol.

What is JSON format?

JSON (JavaScript Object Notation) is a lightweight, human-readable format that supports nested structures, making it ideal for APIs and document-oriented data.

Related Tools