Convert JSON to CSV
Paste a JSON array and the CSV appears as you type. Columns are taken from every object, so a property that only some records have still gets a column of its own.
- Comma
- Semicolon
- Tab
- Pipe
Converted in this tab. An API response pasted here is never uploaded.
How to use it#
- Paste a JSON array, or a single object for a one-row table.
- Pick the delimiter your spreadsheet expects, and decide whether nested objects get their own columns.
- Copy the CSV or download it as a file.
Working out the columns#
JSON records do not have to agree on which properties they carry, and a CSV table does. The columns here are the union of every key across every object, in the order the keys were first encountered rather than alphabetically, because first-seen order usually matches how the data was designed.
A record missing one of those properties gets an empty cell. This is worth knowing because an empty cell in CSV is ambiguous: it could mean the property was absent, or present and null, or present and an empty string. All three come out the same way, and the distinction is not recoverable from the file.
If that distinction matters, CSV is the wrong format for the job and the answer is to keep the JSON.
Nested objects, and the two ways to handle them#
JSON nests and CSV does not, so something has to give. By default a nested object is written into its cell as JSON text, which keeps the data complete and makes the cell unpleasant to read. Turning on flattening instead gives every leaf its own column, named by its path: a user object containing a name produces a column called user.name.
Flattening is usually what you want when the nesting is shallow and consistent, which covers most API responses. It works badly when records nest differently from each other, because the column count grows with the union of every path that appears anywhere.
Arrays are left as JSON either way. Giving each element its own column would make the header depend on whichever record happens to have the longest array, and that is rarely useful.
Opening the result without breaking it#
Excel decides how to split a CSV using the list separator from your system’s regional settings, which is a semicolon in much of Europe. A comma-separated file opened on such a machine arrives with every row crammed into one column. Choosing the semicolon delimiter here avoids that, as does importing the file rather than double-clicking it.
The other classic problem is Excel reformatting values on the way in. Long numbers become scientific notation, anything resembling a date becomes a date, and leading zeroes are stripped. None of that is caused by the CSV, which is plain text and holds exactly what is shown here. Using the import wizard and marking those columns as text is the way to keep them intact.
Frequently asked questions#
What happens to nested objects?
#
By default they are written into a single cell as JSON, which keeps everything but is awkward to read. Turn on flattening and each leaf gets its own column named by its path, so a name inside a user object becomes a column called user.name. Arrays stay as JSON in both cases.
What if my objects have different properties?
#
Every property that appears anywhere gets a column, and records lacking it get an empty cell. The column order follows where each key was first seen rather than the alphabet.
Why does Excel put everything in one column?
#
Excel splits on the list separator from your regional settings, which is a semicolon in many countries. Choose the semicolon delimiter here, or use Excel’s import wizard and tell it the file is comma separated.
Can I convert a single object rather than an array?
#
Yes. A single object becomes a one-row table with its properties as columns, which is what you usually want when converting one API response rather than a collection.
Is my JSON sent anywhere?
#
No. The conversion is JavaScript running in this tab, so an API response containing real records never leaves your machine.