JSON to CSV
Convert an array of JSON objects into CSV rows with headers.
Written by Anil Gautam · Updated
How does JSON to CSV build the columns?
The converter parses your JSON, wraps a single object in an array, and collects every key from every object in the order each first appears. Those keys form the header line. Each object then becomes one row with a cell for every header. Strings are wrapped in double quotes, numbers and true or false are written bare, and a missing key or a null value becomes an empty quoted cell.
Paste [{"name":"Asha","marks":91,"city":"Pune"},{"name":"Ravi","marks":78,"remarks":"Re-test"}] and the header comes out as name,marks,city,remarks. Asha's row reads "Asha",91,"Pune","" and Ravi's reads "Ravi",78,"","Re-test".
Because of that ordering, a key the first object lacks is placed after all of that object's keys. To control the column order, give the first object every key in the sequence you want, even with empty values. String values keep their quotes, which means an ID stored as "0042" arrives in the CSV with its leading zeros, although a spreadsheet may still strip them when it opens the file.
Which JSON shapes break the CSV?
Nested values are the main problem. An array or object inside a record is written as raw JSON text without surrounding quotes, so {"tags":["a","b"]} produces the cell ["a","b"], and a spreadsheet splits it at the comma. Join such lists into one string, or lift nested fields to the top level, before converting. Wrapped API responses are another trap: a body like {"data":[...]} gives one column named data that holds the whole array as text, so paste only the array inside it.
Quotes inside strings are escaped JSON-style with a backslash, as in "He said \"hi\"". CSV readers expect a doubled quote, so that cell may split or show stray backslashes when opened. Line breaks inside strings are written as the two characters \n, which keeps each record on one line. Header names are not quoted, so a key that contains a comma shifts every column after it.
How do I open the CSV in a spreadsheet?
The page has no download button, so copy the output into a plain-text file saved with a .csv extension and open it in Excel, Google Sheets or LibreOffice Calc. Conversion happens in your browser, and nothing is uploaded. If the JSON has a syntax error, such as a trailing comma or single quotes around keys, the output box shows the browser's parser error in place of CSV. JSON Validator formats valid JSON with indentation, which makes nesting easy to spot before you convert. For the reverse direction, use CSV to JSON.