Skip to content
Data4 min read

JSON vs CSV: When to Use Each for Data

Short answer

JSON represents hierarchy and preserves types; CSV is a flat table with no type information that every system can read. Converting JSON to CSV requires flattening the hierarchy, which is lossy in structure even when no values are lost.

Published · Checked

Structure is the real difference

JSON can nest arbitrarily: an object containing an array of objects, each containing further objects. It also distinguishes types — the number 42, the string "42" and the boolean true are all different things.

CSV has rows and columns. There is no nesting, and no types: every value is text until something interprets it.

What flattening does

Converting JSON to CSV means projecting a tree onto a grid. The usual approach, and the one FileTools360 uses, is to join nested keys with dots: a user object with an address becomes columns named address.city and address.zip.

That is predictable and reversible by eye. It breaks down when the data is irregular — if some records have three addresses and others none, you end up with many columns that are mostly empty. That sparseness is a signal the data probably should not be a table.

Arrays of simple values are joined into a single cell. Arrays of objects expand into indexed columns, which gets unwieldy quickly.

JSON and CSV compared
JSONCSV
NestingArbitraryNone
TypesString, number, boolean, nullNone
CommentsNoNo
Size (flat data)Larger — keys repeat per recordSmaller
StreamingAwkwardNatural, line by line
Spreadsheet supportNoUniversal

Going the other way is cleaner

CSV to JSON is straightforward: each row becomes an object keyed by the header row, which is exactly the shape most APIs and scripts expect.

The one decision is type inference. FileTools360 sniffs values so numbers arrive as numbers and booleans as booleans, rather than everything landing as strings — which is almost always what you want, and occasionally not, if your identifiers happen to look numeric.

  • APIs, configuration, nested records → JSON
  • Flat tabular data, spreadsheets, database imports → CSV
  • Very large flat datasets → CSV, which streams and stays small
  • Irregular or deeply nested data → keep it as JSON

Sources

Try it

FAQ

Related questions

Can every JSON file become a CSV?

Technically yes, but not always usefully. Deeply nested or irregular JSON produces a sparse table with many empty cells, which is harder to work with than the original. If the result looks like that, the data wants to stay hierarchical.

Why is my JSON so much bigger than the CSV?

Because JSON repeats every key on every record, while CSV states them once in the header row. For large flat datasets that overhead is substantial — one of the few areas where CSV clearly wins.

Does converting CSV to JSON preserve number types?

Yes — numeric values become JSON numbers rather than strings. Identifiers that only look numeric are the deliberate exception: a zip code written 01234 stays the string "01234", because a digit string padded with a leading zero is an identifier rather than a quantity. This page used to advise quoting such values in the source, and that advice was wrong — quotes come off before typing happens, so "01234" was coerced exactly like 01234. The rule is the leading zero itself now, which protects quoted and unquoted values alike. Genuine numbers are untouched: 0, 0.5 and 0.0 are still numbers.

Runs entirely in your browser

FileTools360 by the numbers

527 converters and tools65 file formatsnothing ever uploaded.