Home JSON to CSV
JSON to CSV converter
Paste a JSON array — or NDJSON, one object per line — and get a CSV file back. It runs in this tab, so nothing is uploaded.
What happens to nested objects and arrays
CSV is flat and JSON is not, so this is the decision that defines the conversion. Two rules, both chosen so that the output keeps the same shape no matter which rows you feed in:
Nested objects become dotted columns. {"user":{"name":"Ada"}}
produces a column called user.name. Nesting goes as deep as your data does, and
the notation matches the dot notation the
builder uses to produce nested JSON, so a file can round-trip through both.
Arrays are JSON-encoded in place. {"tags":["a","b"]} produces a
single tags column containing ["a","b"], not
tags_0 and tags_1. Exploding an array into columns sounds friendlier
until you notice that the number of columns then depends on the longest array in the file:
add one row with three tags and every previously-written file has a different header.
Keeping the array in one cell means the header is a function of the keys alone.
Rows with different keys
Real JSON from an API rarely has identical keys in every object. The column set is the union of every key seen, in the order first encountered, and a row that lacks a key gets an empty cell. Nothing is dropped and nothing shifts:
[{"a": 1}, {"b": 2}]
a,b
1,
,2
Input shapes it accepts
- An array of objects — the normal case, and what most APIs return.
- A single object — converted to a one-row file.
- NDJSON — one JSON object per line, the shape of most log files and BigQuery exports. Detected automatically when the whole input is not valid JSON but every line is.
An array of scalars — [1, 2, 3] — is rejected rather than guessed at. There are
no field names in it, so there is no honest header row to write.
Escaping in the output
Values containing a comma, a double quote, a carriage return or a newline are wrapped in quotes, with inner quotes doubled, per RFC 4180. That is what makes the output safe to feed back into a parser — including the reverse converter, which is the quickest way to check a conversion round-trips.
Opening the result in a spreadsheet
Excel decides the delimiter from your system locale, so on a machine set to a locale that uses commas as decimal separators a comma-separated file lands in one column. Use Data → From Text/CSV rather than double-clicking the file, or convert to TSV instead — tabs are unambiguous. The Excel guide covers the rest of that particular argument.
Common questions
How are nested objects handled?
They flatten to dotted column names: {"user":{"name":"Ada"}} becomes a column called user.name. Nesting goes as deep as the data does.
Why is my array in a single cell?
Because exploding it into tags_0, tags_1 and so on would make the column count depend on the longest array in the file, so adding one row could change the header. The array is JSON-encoded into one cell instead.
Can it convert NDJSON?
Yes. If the input is not valid JSON as a whole but every line parses on its own, it is read as NDJSON — one object per line.
What if my objects have different keys?
The header is the union of all keys, in the order they are first seen, and a row missing a key gets an empty cell. No row is dropped and no value shifts into the wrong column.
Is anything uploaded?
No. The conversion runs in your browser; the JSON never leaves your machine.
Related
- /csv-to-json-converter — the reverse conversion, and the type-detection rules it applies.
- /json-to-sql-converter — the same flattening, but writing CREATE TABLE and INSERT instead.
- /csv — generating CSV test data from a schema rather than converting existing JSON.
- /excel-sample-data — getting a converted file to open correctly in Excel and Sheets.
Last updated