CSV vs JSON vs XML: File Size and Speed Compared

We wrote the same 100,000-row dataset to CSV, TSV, JSON, JSONL, XML and SQL, then measured the file size (raw and gzipped) and how long popular parsers take to read it back.

In one line: JSON ended up 2.12x the size of CSV and XML 2.79x — but after gzip the difference shrank to 1.23x and 1.30x. Size alone is rarely a good reason to change format; the bigger differences are in readability by machines and people.

How we measured

  • One dataset: 100,000 rows × 8 columns (id, first_name, last_name, email, city, category, amount, notes), generated from a fixed seed so it can be reproduced.
  • Each format written the idiomatic way: CSV quoted per RFC 4180, a JSON array, JSONL (one object per line), XML with one element per row, and SQL INSERT statements.
  • gzip at level 6 (a common default).
  • Timings: 5 runs each, median reported, on Node.js.
  • CSV parsing libraries compared: papaparse, csvtojson, @fast-csv/parse and withdata-convert; JSON → CSV with json2csv and withdata-convert.

File size

FormatRawvs CSVgzip (level 6)vs CSV (gz)
CSV7.5 MB1.00x1,542 KB1.00x
TSV7.5 MB0.99x1,539 KB1.00x
JSON16.0 MB2.12x1,898 KB1.23x
JSONL (NDJSON)16.0 MB2.12x1,898 KB1.23x
XML21.0 MB2.79x2,004 KB1.30x
SQL (INSERT)17.4 MB2.31x1,911 KB1.24x

Why JSON and XML are bigger

CSV writes the column names once, in the header row. JSON repeats a key on every row ("first_name":"John"), and XML goes further and wraps every value in its own element (<first_name>John</first_name>) plus a row element. That repeated structure is exactly why JSON is roughly 2x and XML roughly 3x the size of CSV for flat, tabular data.

The same repetition is also why gzip helps so much: the boilerplate compresses extremely well, so the real-world (compressed) penalty of JSON or XML is only about 20–30% — often not worth changing your pipeline for.

JSONL is the same size as a JSON array here, but it can be streamed line by line and appended to, which matters for logs and very large files.

Parsing speed (CSV → JSON, 100,000 rows)

LibraryRows returnedMedianBest
papaparse100,001 ⚠182 ms157 ms
csvtojson100,000290 ms277 ms
withdata-convert100,000614 ms509 ms
@fast-csv/parse100,000776 ms771 ms

All four finish 100,000 rows quickly enough for interactive use. Two things are worth noting:

  • papaparse was the fastest, but it returned 100,001 rows — it treats the trailing newline as an extra (empty) record. The others returned the correct 100,000 rows. Speed and correctness are not the same thing; always check the row count on a file with a trailing newline.
  • These are single-threaded, in-memory, whole-string parses. If your files are large, parse inside a Web Worker so the page stays responsive.

Parsing speed (JSON → CSV, 100,000 rows)

LibraryMedianBest
json2csv167 ms166 ms
withdata-convert261 ms252 ms

Which format should you use?

FormatBest forWatch out for
CSV / TSVFlat tabular data, spreadsheets, database import, the smallest filesNo types, no nesting, quoting rules vary
JSONAPIs, nested data, program-to-program exchange~2x the size of CSV; must load the whole document
JSONL / NDJSONStreaming, logs, append-only files, huge datasetsNot human-friendly; one bad line can break a reader
XMLLegacy systems, documents with mixed content, SOAP, schemas~2.8x the size of CSV; verbose
SQLPortable dumps you can restore into a databaseDialect differences; slower to generate/parse

Frequently asked questions

Is JSON bigger than CSV?

Yes — about 2.12x in our test (16.0 MB vs 7.5 MB). After gzip the difference falls to roughly 1.23x.

Is XML bigger than JSON?

Yes, by about 1.3x (21.0 MB vs 16.0 MB), because XML wraps every value in a start and end tag.

Which is faster to parse, CSV or JSON?

A native JSON.parse is usually far faster than a general-purpose CSV parser, but a CSV file is smaller to read and transfer. For 100,000 rows, the CSV parsers we tested ranged from about 180 ms to 780 ms.

Should I use JSONL instead of JSON?

If you stream or append records — logs, event data, very large files — yes. JSONL keeps one object per line, so it is the same size as a JSON array but can be processed line by line.

How do I convert between these formats?

Use the free online converters (they run entirely in your browser, nothing is uploaded): CSV to JSON, JSON to CSV, XML to CSV, CSV to SQL, and more. For large or batch jobs, use the offline desktop apps.

Reproduce it

Everything above comes from a single script: generate 100,000 rows from a fixed seed, serialise each format, gzip level 6, and time each parser over 5 runs (median). Numbers will shift with the shape of your data, your CPU and your runtime version — treat them as a fair comparison under one consistent setup, not as universal constants.

Convert your own files

If you just want the conversion done, the free online tools handle CSV, Excel, JSON, XML and SQL right in your browser: Withdata Online Data Conversion. For large files, batch conversion or scheduling, see the offline apps and the data conversion tools.