JSON to CSV Converter with Nested Object Flattening
Paste an array of JSON objects, or a single object, and get CSV with one row per object. Nested objects become dot-notation columns such as user.address.city. The CSV is written by Papa Parse.
Related Developer Tools
Runs in your browser: your files and text are not uploaded. Free, no account needed.
Last updated: · Reviewed by the QuickTooly Team
Flattening and quoting rules
How Nested JSON Becomes Columns
With "Flatten nested objects" on (the default), each row is processed like this:
- Nested objects are opened up and their keys joined with dots:
{"user":{"address":{"city":"Oslo"}}}becomes the columnuser.address.city. - Arrays are joined into one cell with "; " between items.
["x","y"]becomesx; y. Objects inside an array are not flattened and come out as[object Object]. nullvalues become empty cells.
With flattening off, a nested object or array is written into one cell as JSON text, such as {"city":"Oslo"}.
Column Headers Come From All Objects
The column list is every key found in any object, in the order the keys first appear. A row that lacks a key gets an empty cell in that column.
Delimiter and Quoting
- Delimiter: comma by default. Semicolon suits spreadsheet apps set to a locale that uses a decimal comma. Tab produces tab-separated values.
- Quoting: a value is wrapped in double quotes when it contains the delimiter, a double quote or a line break. Double quotes inside a value are doubled, so
say "hi"becomes"say ""hi""". - Line endings: rows are separated by CRLF (
\r\n).
Worked example
This input:
[{"id":1,"name":"Ada, L","user":{"address":{"city":"Oslo"}},"tags":["x","y"]},
{"id":2,"name":"Bob"}]becomes:
id,name,user.address.city,tags
1,"Ada, L",Oslo,x; y
2,Bob,,Before You Open the File in a Spreadsheet
- The downloaded file is UTF-8 without a byte order mark. Some versions of Excel then show accented characters incorrectly; use the import wizard and pick UTF-8.
- Values that start with
=,+,-or@are written as they are, and a spreadsheet may treat them as formulas.
JSON to CSV Questions
Why do I get "JSON must be an array of objects or a single object"?
At least one item of your array is not an object, for example a plain string, number, null or a nested array. Wrap each value in an object, such as {"value": "a"}.
Why is a cell empty in my CSV?
That object has no value for the column, or the value is null. Columns are collected from all objects, so a key that only some objects have still gets a column.
Can I turn each array item into its own row?
No. Arrays are joined into a single cell. Reshape the data first so each item is its own object in the top-level array.
Related Tools
- JSONL Viewer: turn a JSON Lines file into a JSON array that this converter accepts.
- JSONPath Evaluator: extract the array of records from a larger API response first.