JSON and CSV: One Nests, One Cannot

Open Tool JSON CSV Converter

The gap between nested and flat

JSON expresses nesting to any depth, with objects holding arrays that hold more objects. CSV has rows and columns, a fixed count per row and text only in each cell. Every difficulty in converting lives in that gap: flattening pushes child structures either into a compact string inside a cell or into dotted column names, while rebuilding applies column-name rules in reverse. The tool does both directions from pasted content and copies results.

Steps

  1. Paste the JSON or CSV and confirm the outer level is an array.
  2. Choose the direction.
  3. Run it and check that columns cover the union of every object's keys.
  4. Verify cells containing commas arrive quoted.
  5. Copy into a file and open it in a spreadsheet to confirm columns line up.
  6. Reset for the next dataset.

Flattening, quoting, types

Flattening takes two routes: serialising child objects into JSON strings keeps everything but leaves cells unreadable, while dotted column names stay sortable and filterable at the cost of a column explosion. Arrays are worse, since unequal lengths leave short objects missing columns that need empty values. Quoting rules require any cell with a comma, a newline or a quote to be wrapped whole and inner quotes escaped, or columns shift. Type is the hidden trap: CSV has none, so everything returns as a string and numbers and booleans need converting. Phone numbers, identifiers and postal codes with leading zeros must stay strings.

Common mistakes

Flattening nested objects and losing every level. Unquoted commas shifting columns. Leading zeros vanishing so an identifier changes value. Long numbers turning scientific in a spreadsheet. Multi-line text splitting a row apart. And uneven arrays leaving rows short.

Where CSV should not be forced

Beyond two or three levels of depth, keep JSON instead of flattening. Types and nesting cannot survive conversion intact. Spreadsheets cap rows, so large datasets need chunking. Fields exposed to formula injection need sanitising before export. And any converted dataset meant for long-term storage keeps the original JSON alongside it.

⏫︎