- Home
- Tools
- Developer Tools
- JSON to CSV Converter
- Convert JSON to CSV
Convert JSON to CSV
Turn a JSON array into CSV for Excel or Google Sheets. Nested objects and lists are spread over columns, and nothing is uploaded.
CSV
How nested JSON is laid out in columns
CSV is a flat grid and JSON can nest as deep as it likes, so every value has to be given a column of its own. Two orders, one of them with fewer fields:
[
{"id": 7, "customer": {"name": "Mila", "city": "Utrecht"}, "tags": ["tea", "books"], "lines": [{"sku": "TP-200", "qty": 1}, {"sku": "GT-015", "qty": 3}]},
{"id": 8, "customer": {"name": "Tom"}, "tags": [], "paid": true}
]id,customer.name,customer.city,tags,lines.0.sku,lines.0.qty,lines.1.sku,lines.1.qty,paid 7,Mila,Utrecht,"tea, books",TP-200,1,GT-015,3, 8,Tom,,,,,,,true
The rules, one at a time
| In the JSON | Header | Row | Rule |
|---|---|---|---|
In the JSON{"city": "Utrecht"} | Headercity | RowUtrecht | A plain value keeps its key. |
In the JSON{"address": {"city": "Utrecht"}} | Headeraddress.city | RowUtrecht | A nested object adds its keys after a dot. |
In the JSON{"tags": ["tea", "books"]} | Headertags | Row"tea, books" | A list of plain values is joined in one cell. The comma between them is why the cell is in quotes. |
In the JSON{"lines": [{"sku": "TP-200"}, {"sku": "GT-015"}]} | Headerlines.0.sku,lines.1.sku | RowTP-200,GT-015 | A list of objects gets numbered columns, counting from 0. |
In the JSON{"paid": true, "note": null} | Headerpaid,note | Rowtrue, | true and false are written out; null leaves the cell empty. |
In the JSON{"name": "Jansen, A."} | Headername | Row"Jansen, A." | Any value with a comma in it is put in quotes, so that it stays one cell. |
In the JSON{"id": 12345678901234567890} | Headerid | Row12345678901234567890 | A number is copied digit for digit, however long it is. |
Good to know
The header is every key that occurs in any row, in the order of first appearance. A row that lacks a key gets an empty cell, which is why the second order above has gaps.
The file follows RFC 4180. A cell is put in quotes only when it needs them: when it contains the delimiter, a quote or a line break, or when it starts or ends with a space. A quote inside it is doubled.
When the JSON is an object around a single list, as in {"total": 2, "data": [...]}, the list gives the rows. A checkbox under the result switches that off.
For Excel in a country that writes decimals with a comma, choose the semicolon as delimiter, and download with the byte order mark so that accented letters arrive intact.
The JSON to CSV converter page has more on delimiters, Excel and cells that start with an equals sign.