JSON to CSV Converter - Flatten Nested Data
JSON to CSV converter
What this tool does
Somebody sent you an API response and somebody else wants it in a spreadsheet. That is the whole job - and it is harder than it looks, because JSON is a tree and a spreadsheet is a grid. This page makes the three decisions that turn one into the other, and shows you what it decided.
How to use it
- 1 Paste the JSON, or drop a .json file.
- 2 Pick the delimiter - use a semicolon if the file is for Excel.
- 3 Press Convert, then copy the result or download the .csv.
A tree does not fit in a grid, so it gets flattened
A nested object becomes a dotted column: {"city":{"name":"London"}} turns into a column called city.name. Without this a converter writes "[object Object]" into the cell - the file opens, looks valid, and half your data is gone. Lists of plain values are joined into one cell; lists of objects get numbered columns instead.
[
{
"name": "Ada",
"city": { "name": "London" },
"note": "Loves \"tea\""
},
{
"name": "Grace",
"city": { "name": "New York, NY" },
"tags": ["math", "navy"]
}
]
name,city.name,note,tags Ada,London,"Loves ""tea""", Grace,"New York, NY",,math; navy
Columns come from every row, not the first one
Records in real data rarely have identical fields: an optional field appears on the fortieth record and nowhere before it. A converter that reads only the first record silently drops that column, and nothing in the output says so. Here the header is the union of every key seen, in the order they first appear, and records missing a field get an empty cell.
One stray comma shifts every column
Any value containing the delimiter, a quote mark or a line break has to be wrapped in quotes, and quotes inside it doubled. That is what the CSV standard asks and it is the part converters most often get wrong. An address with a comma in it, a comment with a line break, a name with an apostrophe - each of them silently breaks a file that skips this step.
Excel breaks CSV files in two different ways
First, without a byte-order mark it reads UTF-8 as the local code page, so accented and non-Latin characters turn to mush. Second, in many locales it expects a semicolon, not a comma, and puts every row into a single column. Both are options here, and both default to off - because the standard says comma and no mark, and the file usually goes to a script rather than a spreadsheet.