Why convert JSON to CSV?
JSON is what APIs return. CSV is what spreadsheets open. Almost every conversion between the two starts with the same problem: someone has a JSON response from an API, an export from a database or a log file, and they need it in Excel, Google Sheets or a BI tool that has never heard of a nested object.
The conversion is straightforward when the JSON is a flat array of objects with identical keys. It stops being straightforward the moment records nest, keys differ between records, or the data contains commas, quotes and line breaks — which real data always does.
What the converter accepts
The [msm_tool slug="json-to-csv"] accepts any of these shapes:
- An array of objects — the common API response shape. Each object becomes a row and each key becomes a column.
- An array of arrays — already row-shaped, converted directly.
- A single object — converted to one row.
Keys do not have to match across records. The converter collects every key it encounters and leaves cells blank where a record does not have that key, rather than dropping the column or failing.
Handling nested objects
Nesting is where most converters either give up or quietly mangle the data. You get two options.
Flatten to dotted columns walks into nested objects and builds column names from the path. A record like {"user":{"name":"Ada","city":"London"}} becomes two columns, user.name and user.city. This is usually what you want, because the result is genuinely tabular and every value is filterable and sortable in a spreadsheet.
Keep as JSON in one cell leaves the nested structure serialised inside a single cell. Useful when the nested part is a payload you want to preserve intact rather than analyse — for example a settings blob you intend to feed back into another system.
The four options that decide whether Excel opens your file correctly
Delimiter
Comma is standard, but it is the wrong choice in much of Europe. In locales where the comma is the decimal separator, Excel expects semicolon-delimited files and will otherwise cram every row into a single column. Tab and pipe are the safest choices when your data itself contains punctuation.
Add a UTF-8 BOM
This is the fix for the single most common complaint about CSV files: accented characters and non-Latin scripts arriving as mojibake when opened in Excel. Excel does not assume UTF-8, and without a byte order mark it guesses — usually wrongly. If your data contains anything beyond plain ASCII, turn this on.
Quote every field
By default only fields that need quoting get it. Quoting everything produces a larger file but removes any ambiguity, which some strict parsers prefer.
Neutralise spreadsheet formulas
This one is a security control rather than a formatting preference, and it deserves its own section.
CSV injection, and why the formula option matters
If a cell value begins with =, +, - or @, Excel and Google Sheets interpret it as a formula rather than as text. That is a genuine attack path: an attacker who can get text into your database — through a signup form, a support ticket, a product review — can plant a value that executes when someone exports the data and opens it in a spreadsheet. The technique is well documented and is usually called CSV injection or formula injection.
Enabling Neutralise spreadsheet formulas prefixes those values so the spreadsheet treats them as plain text. If the JSON you are converting contains anything that originated from user input, leave this on. The cost is a harmless prefix on a handful of cells; the alternative is executing a stranger's formula on your machine.
How to convert JSON to CSV
- Paste your JSON into the input box.
- Choose a delimiter, and decide how nested values should be handled.
- Set the header row, quoting, BOM and formula options to suit where the file is going.
- Convert, then copy the result or download it as a
.csv file.
Everything runs in your browser. The JSON is not uploaded, which matters when you are converting an API response that contains customer records, tokens or internal identifiers.