What the JSON to CSV converter does
The converter turns a list of JSON objects into a CSV table: every object becomes a row and every key a column. Columns are gathered from all the rows, in the order their keys first appear, so an object that lacks a key simply leaves that cell empty. Values are copied from your text rather than recalculated, which means a price of 84.90 or a 20-digit order number reaches the CSV unchanged. The file follows RFC 4180 (opens in a new tab): a cell that contains the delimiter, a double quote or a line break is wrapped in double quotes.
How to convert JSON to CSV
- Paste JSON into the input, or open or drop a
.jsonfile. When the rows sit inside a wrapper such as{"data": [...]}, the converter finds them by itself. - Pick the Delimiter: a comma suits most programs, a semicolon suits Excel in countries that write decimals with a comma.
- Choose how lists are written with Arrays, and keep Export mode on Spreadsheet-safe whenever someone may open the file in a spreadsheet.
- Check the preview below the output, then copy the CSV or download it as a
.csvfile. Swap direction carries the result over to CSV to JSON.
Examples
Input
[{"id":1,"user":{"name":"Ada"},"tags":["a","b"]}]
Output
id,user.name,tags
1,Ada,a;b
Input
[{"note":"=1+1"},{"note":"-12.5"},{"note":"@SUM(A1)"}]
Output
note
"'=1+1"
-12.5
"'@SUM(A1)"
Input
{"data":[{"id":12345678901234567890,"active":true},{"id":2,"active":null}],"total":2}
Output
id,active
12345678901234567890,true
2,
The examples show line breaks as LF. The converter writes CRLF unless you set Line endings to LF.
Flattening nested JSON
A table has no room for nesting, so each nested value gets a column named after the keys that lead to it. With the default dot separator, {"customer": {"address": {"city": "Leeds"}}} produces the column customer.address.city. An empty object stays visible as the text {} in its own column, so nothing silently disappears.
Two different paths can end up with the same name: a key that is literally called user.name next to a user object with a name key. The second column is then written as user.name_2, and the Problems list says so. If your keys contain dots, choose a slash or an underscore as the Key separator instead. To keep a nested object together in one cell, set Nested objects to JSON text.
Arrays: join, JSON text or columns
Lists need a decision, because one row has room for one value per column:
- Join values writes a list of plain values into one cell, separated by the Join with character:
["a","b"]becomesa;b. It reads well in a spreadsheet, but a value that contains the separator becomes ambiguous. A list that holds objects or other lists is written as JSON text instead, since joining it would lose its structure. - JSON text keeps the whole list in one cell as compact JSON,
["a","b"]. Nothing is lost, and CSV to JSON can turn the cell back into a list with Parse JSON in cells. - Indexed columns spreads the list over
tags.0,tags.1and so on. It fits short lists of a fixed length, such as coordinates. Long lists produce many columns, and the converter stops at 10,000 columns.
Opening the CSV in Excel
CSV has no way to state its text encoding. Excel on Windows assumes the computer's legacy code page unless the file starts with a byte order mark, which garbles letters like é, ü or €. Turn on Excel compatibility (UTF-8 BOM) for files that will be opened by double-clicking in Excel; Google Sheets and most programs read UTF-8 either way.
Excel also splits a row at the list separator of the computer's regional settings. Where the decimal mark is a comma, as in Germany, France or Turkey, that separator is a semicolon, so a comma-delimited file opens as a single column. Set Delimiter to Semicolon for those readers. Line endings default to CRLF, the RFC 4180 choice; Excel and nearly every other program accept LF as well.
Formula injection and the spreadsheet-safe export
Spreadsheets treat a cell that begins with =, +, - or @ as a formula. When the values come from users, such as a name typed into a web form, a cell like =HYPERLINK("https://example.com","Click here") turns into a live link the moment someone opens the export. Payloads of this kind are known as CSV injection (opens in a new tab).
The default Spreadsheet-safe export writes an apostrophe in front of text that starts with one of those characters, or with a tab or a carriage return, and quotes the cell, so the spreadsheet displays it as text. Numbers, true, false, null and text that is a plain number, like -12.5, are left alone, because they cannot be formulas. Some spreadsheets show the apostrophe in the cell: that is the price of the protection.
Raw export writes every cell unchanged. Use it only when the CSV goes into a database or another program, never to a person with a spreadsheet; the tool shows a warning while Raw is selected. To undo the apostrophes later, CSV to JSON has a Remove spreadsheet-safe prefix option.
Finding the rows in an API response
API responses usually wrap their list: {"data": [...], "total": 120}, or {"items": [...], "next": null}. When the root of your JSON is an object, the converter takes the first key whose value is a non-empty list, in the order the keys are written, and notes the path it used, such as $.data. An object without any list becomes a single row.
To use a different list, write its path under More options > Rows: $.results, $.response.items, $["line items"] or $.pages[0].rows. The path is kept only while the page is open; it is not saved with the other options, because it can contain names from your data.
Options
| Option | Values | Default | When to change it |
|---|---|---|---|
| Delimiter | Comma (,), Semicolon (;), Tab, Pipe (|) | Comma (,) | The character between cells. Choose Semicolon for Excel with a decimal comma, Tab for pasting into other tools. |
| Arrays | Join values, JSON text, Indexed columns | Join values | How a list fits in a row: joined into one cell, kept as JSON, or spread over numbered columns. |
| Export mode | Spreadsheet-safe, Raw | Spreadsheet-safe | Keep Spreadsheet-safe for anything a person may open in a spreadsheet; Raw is for databases and programs. |
| Header row | On, Off | On | Turn it off when the file is appended to an existing table that already has a header. Lists of lists never get one. |
| Excel compatibility (UTF-8 BOM) | On, Off | Off | Starts the downloaded file with a byte order mark, so Excel on Windows reads accented letters correctly. |
| Nested objects | Columns by key path, JSON text | Columns by key path | Choose JSON text to keep each nested object in one cell instead of a column per key. |
| Key separator | Dot (.), Slash (/), Underscore (_) | Dot (.) | The character between the keys of a column name. Change it when your keys contain dots. |
| Join with | Semicolon (;), Comma (,), Pipe (|), Space | Semicolon (;) | The character between the values of a joined list. Pick one that does not appear in the values. |
| Null values | Empty cell, The text null | Empty cell | Write null as the text null when an empty cell must stay distinct from an empty string. |
| Quote all fields | On, Off | Off | Puts every cell in double quotes, for importers that expect it. By default only cells that need quotes get them. |
| Line endings | CRLF (Windows), LF (macOS, Linux) | CRLF (Windows) | CRLF is what RFC 4180 specifies; choose LF for Unix tools that count a carriage return as part of the last cell. |
| Duplicate keys | Error, Use last value | Error | By default an object that repeats a key stops the conversion. Use last value keeps the last one, as JavaScript does, and lists the ones it drops. |
Common errors and fixes
| Code | What it means | How to fix it |
|---|---|---|
CSV_Error | The JSON is a single string or number, or its list mixes kinds of items, such as objects and plain text. | Make the rows a list of objects, or point Rows at the list you want; the message names the first item that does not fit. |
JSON_Error | One object names the same key twice, and a table cell can hold only one of the values. | Remove the member you do not want, or set Duplicate keys to Use last value. |
CSV_Warning | Flattening gives two different paths the same column name, usually because a key itself contains the separator. | Choose another Key separator, or rename the key. |
CSV_Error | Indexed columns or deep nesting would create more than 10,000 columns. | Set Arrays to JSON text or Join values, or Nested objects to JSON text. |
JSON_Warning | A string holds half of an escaped emoji or other character outside the basic plane, which UTF-8 cannot store. | Repair the escape pair in the source data; the CSV shows the replacement character in its place. |
When the input is not valid JSON, the converter lists the syntax errors instead; the JSON Formatter explains each one with an example of the fix.