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

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

Try it

FAQ

Related questions

Runs entirely in your browser

FileTools360 by the numbers

521 converters and tools65 file formatsnothing ever uploaded.