Practical guidesText & code

Convert JSON to CSV.

Turn a JSON array of objects into CSV. Columns are the union of keys, missing values become empty cells, and nested values are written as JSON text.

Open the CSV to JSON converter

Use an array of objects

Open the CSV to JSON converter and set Convert to JSON → CSV, or press Swap direction if you have just come from a CSV conversion. Paste a JSON array of objects into the input. A single object is treated as an array of one item. An array of row arrays is also accepted, and is written out as rows without inventing column names.

The JSON must be valid. A number outside the safe integer range is refused, because it cannot be converted exactly; put long identifiers in quotes, for example "9007199254740993".

Example input

[
  {"name": "Notebook", "sku": "00123", "qty": 4},
  {"name": "Pen, blue", "sku": "00456", "colour": "blue"}
]

Read the columns as a union of keys

With Header row ticked, the first CSV row lists every key that appears, in the order each key is first seen. Later objects that omit a key leave that cell empty. In the example, qty is blank on the second row and colour is blank on the first. A cell that contains the delimiter, a quote or a line break is wrapped in double quotes.

Choose Comma (,), Semicolon (;) or Tab as the CSV delimiter to match the spreadsheet or system that will import the file.

Example result

name,sku,qty,colour
Notebook,00123,4,
"Pen, blue",00456,,blue

Know how nested values are written

Nested objects and arrays are not expanded into extra columns. They are written as JSON text in a single cell, with quotes escaped for CSV. null and missing properties become empty cells. Dates and other types become their string form.

Turn off Header row if you do not want a header line; the same columns are still used, in the same order, without the key names in the first row.

Example result

name,dims
Notebook,"{""w"":10,""h"":20}"

Check the result before importing it

Copy or download the CSV and open it in the destination spreadsheet or importer. Confirm that identifiers such as 00123 still have their leading zeros, and that quoted cells have not been split into extra columns.

If you need a Markdown table or a JSON array of row arrays instead, use the table converter. To convert CSV back into objects, follow the CSV-to-JSON guide. The conversion runs in your browser.

Open the CSV to JSON converter