Toolerax logoToolerax
·7 min read

How to Convert JSON to CSV

JSON is how APIs talk; CSV is how spreadsheets listen. Sooner or later you have a chunk of JSON and someone wants it in Excel. This guide explains how the conversion actually works — including the two parts everyone gets wrong: nested objects and escaping.

The basic mapping: objects become rows

A CSV is a grid: rows and columns. JSON that converts cleanly is therefore an array of objects, where each object is a row and each key is a column:

[{"name":"Ada","born":1815}, {"name":"Alan","born":1912}]

becomes a header row of name,bornfollowed by one line per object. If your objects don't all share the same keys, the safe approach is to use the union of every key seen, leaving blanks where a row lacks a value.

Flattening nested objects

Real API responses nest. A CSV cell can't hold a sub-object, so the standard trick is to flatten nested keys into dotted column names:

{"user":{"id":1,"city":"Paris"}} → columns user.id and user.city.

This keeps the structure legible in a spreadsheet without losing information. Arrays inside a record are trickier — there is no single right answer — so a practical default is to serialise them back to compact JSON inside the cell rather than silently dropping them.

The escaping rule that saves your data

Here is the bug that ruins spreadsheets: a value that itself contains a comma. The name “Sam, Jr.” would split across two columns and shift every field after it. The CSV standard (RFC 4180) fixes this with one rule: if a value contains the delimiter, a double quote or a line break, wrap the whole value in double quotes and double any inner quotes.

So Sam, Jr. becomes "Sam, Jr." and 5' 10" becomes "5' 10""". Any converter you trust must do this — doing it by hand is exactly where data gets corrupted.

CSV vs TSV: which to pick

CSV uses commas; TSV uses tabs. TSV is often safer for Excel because tabs appear in data far less often than commas, so there is less to escape. If you paste directly into a spreadsheet, a TSV frequently drops into columns with no import dialog at all. Some European locales default to semicolons because the comma is a decimal separator — pick whichever your target expects.

Watch out for type coercion

CSV has no types — everything is text. That matters when a spreadsheet re-interprets your data: leading zeros on a zip code vanish, long numbers turn into scientific notation, and strings that look like dates get reformatted. If those columns matter, you may need to import as text rather than letting the spreadsheet guess.

Do it privately, in your browser

You should not paste customer records or API keys into a random website that uploads them. A client-side converter does the whole job in your browser, so the data never leaves your machine. Our JSON to CSV converter flattens nested objects, escapes values correctly, and lets you download CSV or TSV — all locally.

Going the other way

Need the reverse? Use the CSV to JSON converter. And if your JSON is messy to begin with, clean it up first with the JSON formatter and validator so you catch syntax errors before converting.

Tools mentioned in this article