Comparison
JSON vs CSV: which format for your data?
Structured JSON or flat CSV for your data export, API, or pipeline? A developer comparison with benchmarks, tooling notes, and clear recommendations.
Last updated:
TL;DR
Use CSV for tabular data that non-developers consume in Excel or Google Sheets. Use JSON for APIs, nested data, or anywhere types matter. For analytics pipelines, Parquet or Arrow beats both — but CSV and JSON remain the lowest-common-denominator formats.
Option A
JSON
Structured, nested, typed
Option B
CSV
Flat, universal, spreadsheet-ready
[object Object]
[object Object]
Side-by-side
| Dimension | JSON | CSV |
|---|---|---|
| Structure | Nested, hierarchical | Flat (rows × columns) |
| Types | string, number, bool, null | All strings (parser must guess) |
| File size | Larger per row | Smaller per row |
| Excel support | Poor (needs conversion) | Native |
| Streaming | JSON Lines for streams | Line-by-line natural |
| Nesting support | Full | None (must flatten) |
| Tooling | Every modern stack | Every tool everywhere, going back decades |
| Schema | JSON Schema (optional) | Header row only |
| Human readability | Good for small data | Great for tabular data |
CSV's enduring strengths
[object Object]
[object Object]
JSON's strengths for engineers
[object Object]
[object Object]
Performance and size
[object Object]
- [object Object]
[object Object]
Common pitfalls
[object Object]
[object Object]
When neither wins: Parquet, Arrow, JSON Lines
[object Object]
[object Object]
Frequently asked questions
Why does Excel mangle my CSV?
Locale — Excel picks the delimiter from your OS locale. Save as TSV (tab-separated), or prepend `sep=,` as the first line, or use Data → From Text/CSV → specify delimiter manually.
Is there a CSV spec?
Yes, RFC 4180 — but few tools follow it strictly. Quoting rules, line endings, and encoding are the main areas of divergence. Always test with your actual consumers.
How do I validate CSV like JSON Schema?
Tools like `frictionless data` and `csvlint` let you declare a schema (types, ranges, required columns) and validate. Not as widespread as JSON Schema, but mature.
Which format should my public API export offer?
Both. Offer JSON for programmatic consumers, CSV for Excel users. Most modern SaaS (Stripe, Mailchimp, Shopify) already does this with a `?format=csv` query param.
