DEVELOPER GUIDE

How to convert JSON records to CSV safely

Turn an array of JSON objects into spreadsheet rows while handling missing fields, nested values, and CSV formulas.

5 min read•DevToolbox editorial

Start with records, not a single object

A CSV file has one row per record. This converter expects a JSON array of objects, even for one row. It collects property names from every record, so a field present only in a later record still becomes a column. A missing field produces an empty cell.

Input:  [{"name":"Alex"},{"name":"Sam","role":"Designer"}]
Output: name,role
        Alex,
        Sam,Designer

Know what happens to nested data

CSV cells cannot preserve a nested object as separate columns by themselves. DevToolbox writes an object or array as compact JSON inside one quoted cell. If you need columns such as address.city, flatten your data before conversion. That choice depends on the structure you want in the spreadsheet.

Input:  [{"name":"Alex","tags":["dev","writer"]}]
Output: name,tags
        Alex,"[""dev"",""writer""]"

Commas and line breaks need quoting

A CSV field containing a comma, quotation mark, or line break is wrapped in double quotes. Quotes inside that field are doubled. This lets a CSV reader distinguish a line break inside a cell from the start of a new record.

Protect spreadsheet imports from formulas

Spreadsheet software can interpret cells beginning with =, +, -, or @ as formulas. The converter's safety option is on by default and prefixes potentially executable values with an apostrophe. Keep it on for untrusted data; review the output and choose appropriate column formats before importing.

Put it into practice with a free tool that runs in your browser.
Open JSON to CSV