VizSoup

JSON to CSV converter (and back)

Paste an array of JSON objects to get a CSV you can open in a spreadsheet, or switch direction and turn CSV into JSON. Nested objects, arrays and missing keys are handled, and the rules are listed below.

Direction
Sample: three invented user records with a nested address, an array and a missing email.
3 records, 7 columns.

How to use it

For JSON to CSV, paste an array of objects: [{...}, {...}]. That is the shape most APIs and database exports produce. If the array is wrapped in an object, as in {"data": [...]}, the first property holding an array of objects is used. A single object becomes one row. For CSV to JSON, switch direction and paste CSV with a header row; each row becomes an object keyed by the column names. Either way, the output updates as you type.

The conversion rules

JSON to CSV

CSV to JSON

Worked example

The sample has three records. The union of their keys gives seven columns: id, name, email, address.city, address.postcode, tags and active. Ben has no email, so his email cell is empty. His tags array is empty and is written as []. Chloé's name contains a comma, so it is wrapped in quotes: "Chloé Martin, Jr.". The accented é passes through unchanged, because everything is handled as Unicode text.

Copy that CSV, switch direction and paste it back, and you get the three records again, with address rebuilt as a nested object and id as a number. Two things do not come back identically. The tags come back as the string ["admin","beta"] rather than an array, because a CSV cell cannot say it holds JSON. Ben's missing email comes back as null, because CSV has no way to tell "missing" from "empty".

Limits

Deeply nested data with arrays of objects, such as an order with many line items, does not fit a flat grid well. The line items stay as JSON text in one cell rather than being spread over several rows. For that shape, convert the inner array on its own. JSON must be strictly valid: no comments, no trailing commas and no single quotes. The error message shows where the parser gave up, which is usually at or just after the first problem. Very large files, tens of megabytes, work but can make the browser tab slow while the text box redraws.

Once the data is in CSV, the table converter can turn it into Markdown or HTML, and the pivot table can summarise it.

Common questions

How are nested objects turned into columns?

Each nested key becomes a column named with the path to it, joined by dots. {"address": {"city": "Leeds"}} becomes a column called address.city. Going the other way, tick "Rebuild nested objects" and a column called address.city becomes a city key inside an address object again.

What happens to arrays?

By default an array is written into its cell as JSON text, such as ["admin","beta"], which keeps the structure and can be converted back exactly. If you only need something readable in a spreadsheet, choose "Join with semicolons" and a list of plain values becomes admin; beta. Arrays of objects are always kept as JSON text.

Why did some records get empty cells?

Records in a JSON array do not have to share the same keys. The CSV has one column for every key that appears in any record, in the order first seen, and a record that lacks a key gets an empty cell there. Null values are also written as empty cells.

Why did my ZIP code or ID stay as text when converting CSV to JSON?

Deliberately. A value is only turned into a JSON number if it survives the round trip unchanged. 02134 would become 2134 and lose its leading zero, and very long IDs lose digits beyond about 15 significant figures, so both stay strings. Plain numbers like 42 or -1.5 become numbers, and true, false and null become their JSON types.

Will Excel open the CSV correctly?

The download is UTF-8 with standard quoting, which current Excel opens correctly by double-click in most setups. If accented characters look garbled, use Data > From Text/CSV and choose UTF-8. In regions where Excel expects semicolons, choose the semicolon delimiter before downloading.

Other tools