Skip to main content

Convert between JSON and CSV formats.

All calculations performed locally in your browser. No data sent to server.

Results are for informational purposes. Verify results with other sources.

Converting between JSON and CSV

JSON nests; CSV is flat. Converting one to the other is easy when the data is a plain array of objects with the same keys, and lossy the moment it is not. Knowing where the loss happens is most of the skill.

How it works

  • JSON → CSV: takes an array of objects, uses the union of all keys as the header row, and writes one row per object.
  • CSV → JSON: treats the first line as headers and produces an array of objects, with every value a string unless you ask for type inference.
  • Quotes any field containing a comma, a quotation mark or a newline, and doubles internal quotes, per RFC 4180.
CSV quoting rules (RFC 4180)
  contains , " or newline  → wrap the field in double quotes
  contains "               → double it: "  becomes ""

  Smith, John  →  "Smith, John"
  5" pipe      →  "5"" pipe"

Worked example

Two records where the second has a field the first does not, and a value containing a comma.

  1. [{"name":"Ada","city":"London"},{"name":"Smith, John","city":"Paris","role":"dev"}]
  2. union of keys → name, city, role
  3. row 1 → Ada,London, (role is empty, not omitted)
  4. row 2 → "Smith, John",Paris,dev

The header carries all three columns and the missing role becomes an empty cell. The comma inside "Smith, John" forces quoting — without it the row would silently gain a column.

Reading the result

  • Nested objects and arrays have no CSV equivalent. They are either flattened into dotted column names (address.city) or serialised back to a JSON string inside one cell. Decide which before converting, because the round trip is not automatic.
  • CSV has no types. Everything comes back as a string, and a leading zero in a postcode or product code will be destroyed by a spreadsheet that decides the column is numeric.
  • Excel expects a UTF-8 byte-order mark before it will render accented characters correctly. Without it, names in Polish, French or Spanish arrive mangled.
  • Line endings differ: RFC 4180 specifies CRLF, but Unix tooling emits LF. Most parsers accept both, some do not.

Common questions

Why did my leading zeros disappear?
The spreadsheet, not the converter. Excel and Sheets infer types on open and treat 00123 as the number 123. Import as text explicitly, or prefix values with an apostrophe, to keep them intact.
How are nested fields handled?
This tool flattens one level into dotted headers and serialises anything deeper as JSON text in the cell. If your data is deeply nested, CSV is the wrong destination format — the conversion will technically succeed and be unusable.