Back to articles index
Format comparisons

CSV vs TSV vs JSON — which data exchange format should you pick?

Compare three data exchange formats for spreadsheet exports, API responses, and ETL pipelines by structural expressiveness, parsing ease, and tool support. Covers CSV escape hell and JSON size bloat.

Four axes — structure, delimiter, compatibility

Choosing a data interchange format usually comes down to four axes. Structural expressiveness decides whether a flat 2-D table is enough or whether you need nested hierarchies. Delimiter and escape complexity drives parser difficulty and the failure mode when the data itself contains the delimiter. Compatibility tightens as soon as the file leaves your machine — Excel, a SaaS import wizard, or a legacy system can each impose different demands. Type information matters when you want numbers, booleans, and null to be distinguishable rather than collapsed into strings.

There is no one-dimensional ranking where “CSV is legacy and JSON is the modern answer.” Pushing JSON into an Excel-driven workflow creates more friction than it removes, and shipping CSV from an API forces you to invent ad-hoc conventions for nested structures. The right axis weights are dictated by who consumes the file next.

Side-by-side comparison

PropertyCSVTSVJSON
StructureFlat (2-D table)Flat (2-D table)Hierarchical (objects, arrays, nesting)
DelimiterComma ,Tab \tSyntax ({}, [], :, ,)
EscapingWrap in ", double internal " to ""Mostly none (tabs/newlines disallowed in cells)Backslash escapes (\", \n, \u00XX)
Newlines in cellsAllowed inside quotes (implementations vary)Not supportedEncoded as \n inside strings
TypesEverything is a stringEverything is a stringstring / number / boolean / null / object / array
StandardRFC 4180 (2005)IANA text/tab-separated-valuesRFC 8259 (2017) / ECMA-404
MIME typetext/csvtext/tab-separated-valuesapplication/json
Excel friendlinessOK (but UTF-8 BOM headaches)Excellent (copy/paste safe)Limited (Power Query route)
EncodingUTF-8 + BOM or Shift_JIS in practiceSameUTF-8 effectively the only choice

Most CSV pain is concentrated in escaping. A single cell containing Hello, "world" has to be written as "Hello, ""world""", and a single misplaced quote can throw the parser off and shift every subsequent row by one column. On top of that, Excel often interprets a UTF-8 CSV as Shift_JIS and mangles non-ASCII characters; the usual fix is to write a UTF-8 BOM (EF BB BF) at the start of the file or to import via Excel’s data wizard with an explicit encoding. TSV sidesteps most of that by simply forbidding tabs and newlines inside cells — the escape rules disappear, which makes it the natural choice for machine-generated logs and one-liner scripts, but a poor fit for free-form text containing literal tabs. JSON expresses hierarchy and types cleanly, but it is verbose for tabular data and typically lands 1.5–2× the size of an equivalent CSV.

Pick-by-use-case

Excel review or human editing: CSV. Normalise it to UTF-8 with BOM via csv-encoding-convert so Excel does not mojibake your Japanese or accented characters. The BOM is the single switch that decides whether Excel guesses correctly.

Paste from a script, columns line up at a glance: TSV. Commas appear inside English prose all the time; tabs almost never do. The escape rules are minimal, and TSV pastes neatly into Slack, GitHub issues, and code blocks with monospace alignment.

API responses, configuration files, nested records: JSON. Arrays inside objects inside arrays are only natural in JSON, and a parser that distinguishes "42" from 42 and false from "false" makes downstream validation much simpler.

Bulk transfer between backends: CSV or TSV, ideally gzipped. Row-oriented streams compress to 10–20 % of the original size and are easy to process line-by-line. JSON repeats every key on every record, so it loses on bandwidth and disk.

Bridging Excel into another tool: TSV. Selecting cells in Excel and copying puts TSV on the clipboard, so a TSV parser on the receiving end skips one conversion step.

Converting locally without uploading

Even when the target format is decided, the data usually arrives in something else. csv-json-convert converts between CSV and JSON locally, with control over header handling and how nested structures are flattened or expanded. When a UTF-8 CSV opens as garbled text in Excel, or a legacy system needs Shift_JIS, csv-encoding-convert handles BOM insertion, BOM stripping, and encoding conversion. Both tools process the input through TextDecoder and TextEncoder in the browser; there is no code path that ships the file to a server.

One thing to watch: recovering a CSV with broken escaping is genuinely hard. If a quote is unbalanced on row 50, the JSON output can silently shift every subsequent value into the wrong field. It pays to inspect the suspect row in a text editor first, or to run something like csv-stats to flag rows whose column count looks wrong before converting. The implementation is open on GitHub, and the DevTools Network tab makes it easy to confirm that nothing leaves the browser during conversion.