Ctrl K

CSV vs JSON: Choosing the Right Data Format

beginner TheToolSera Team 6 min read Updated 27 May 2026

CSV and JSON both store data as text, but they model it differently. CSV is a table; JSON is a tree. Picking the one that matches the shape of your data avoids a lot of conversion pain later.

The same records, both ways

CSV
id,name,city,orders
1,Ada,London,12
2,Grace,New York,7
JSON
[
  { "id": 1, "name": "Ada",   "city": "London",   "orders": 12 },
  { "id": 2, "name": "Grace", "city": "New York", "orders": 7 }
]

For flat, uniform rows CSV is dramatically more compact — the field names appear once instead of on every record. Add one nested field and that advantage disappears.

Comparison

AspectCSVJSON
StructureFlat table onlyArbitrary nesting
Size (flat data)Smallest2–4× larger
TypesEverything is a stringNumbers, booleans, null, arrays
StreamingLine by line, triviallyNeeds a streaming parser or NDJSON
Spreadsheet supportNativeRequires conversion
SchemaHeader row only, by conventionJSON Schema available
EscapingQuoting rules with dialect variationWell specified
Human readabilityExcellent for tablesExcellent for records

CSV's rough edges

  • There is no single CSV standard — separators, quoting and line endings all vary
  • Locales that use a comma as the decimal separator often export semicolon-delimited files
  • Fields containing commas, quotes or newlines must be quoted, and quotes doubled inside
  • Leading zeros and long identifiers are mangled by spreadsheet auto-typing
  • Character encoding is not declared in the file, so UTF-8 is frequently misread

Never split CSV lines on commas with a simple string split. A quoted field can legally contain commas and newlines. Use a real parser.

Choosing between them

  • Use CSV for tabular exports, spreadsheet handoff, bulk database loads and analytics files
  • Use JSON for API payloads, configuration, nested records and anything with optional fields
  • Use NDJSON — one JSON object per line — when you want JSON's structure with CSV's streamability
  • Use Parquet instead of both when datasets grow into the gigabytes

Converting between them

JSON to CSV requires flattening: nested objects become dotted column names such as address.city, and arrays either become indexed columns or a joined string. Both are lossy in the sense that the original shape has to be reconstructed by convention. CSV to JSON is simpler, but every value arrives as a string, so types must be inferred or declared.

Flattening a nested record for CSV
{ "id": 1, "address": { "city": "London" }, "tags": ["a","b"] }

id,address.city,tags
1,London,"a|b"

CSV to JSON

Convert CSV to a typed JSON array with delimiter detection, in the browser.

Try CSV to JSON

Common mistakes

Opening a CSV in a spreadsheet and re-saving it

Auto-formatting silently converts identifiers to dates and strips leading zeros. Import as text instead.

Assuming the delimiter is a comma

Detect it. Semicolons and tabs are extremely common in exports from European systems.

Loading a huge JSON array into memory

Use NDJSON so records can be processed one line at a time.

Flattening without documenting the convention

If consumers do not know how nesting was encoded, the data cannot be reconstructed reliably.

Frequently asked questions

Is CSV smaller than JSON?

For flat, uniform data, considerably — field names are stored once. For nested or sparse data the gap closes or reverses.

Can CSV store nested data?

Not natively. Nesting has to be flattened into dotted column names or serialised into a single field, which both rely on convention.

Which format is better for large datasets?

CSV or NDJSON, because both stream line by line. A single large JSON array must usually be parsed in full.

Does CSV preserve data types?

No. Every field is text, so consumers infer or declare types. This is the main reason exports lose leading zeros.

Put this into practice

CSV to JSON runs entirely in your browser — no upload, no account, no limits.

Open CSV to JSON

Related tools

Related guides

All guides

Explore related topics