JSON to CSV Converter

Convert an array of JSON objects into a CSV table. Everything runs in your browser.

Advertisement

Why convert JSON to CSV

JSON is the shape APIs speak and CSV is the shape spreadsheets and bulk-import screens eat. When a ticket arrives with a JSON dump of two hundred orders and the answer has to go back as a spreadsheet, converting beats writing a throwaway script. The same goes for seeding a database, handing data to a colleague who does not code, or simply scanning a response to see which fields are actually populated.

This converter reads a JSON array of objects and writes one row per object. The keys of the first object become the header row, in the order they appear, and a key that is missing from a later object produces an empty cell in that column rather than shifting the rest of the row to the left.

Quoting, the part that breaks naive converters

CSV is not just values separated by commas. RFC 4180, the specification that describes the format, requires a field to be wrapped in double quotes when it contains a comma, a double quote or a line break, and any double quote inside such a field must be doubled. A product named Widget, large is written as "Widget, large", and a measurement of 12" screen becomes "12"" screen. Fields without those characters stay bare, which keeps the file readable for a human.

This tool applies that rule automatically, which is why a value containing a comma does not split into two columns when the file opens. Rows are separated by a newline, which Excel, Numbers, LibreOffice and Google Sheets all accept; the strict RFC form uses a carriage return and line feed pair, and the difference does not matter to those programs.

Limits worth knowing before you paste

Because the header row is taken from the first object, a key that appears only in later objects is dropped without a warning. If the records are not uniform, normalise them first or check that the first object is the most complete one. Nested objects and arrays are the other trap: values are stringified, so a nested object arrives as the text object Object, and an array becomes a comma-joined list that then gets quoted. Flatten nested data before converting if the structure matters.

Numbers and booleans are written as their text form, so a column of prices loses its numeric type. Spreadsheets usually re-detect numbers on import, but a script reading the file will see strings. The input must be an array of objects: a single object, an array of arrays or an empty array returns an error message instead of output. If the goal is only to read the data rather than move it into a spreadsheet, the JSON formatter will indent and validate the same payload without dropping anything.

An example: two hundred orders, one spreadsheet

You receive an array of order objects with id, customer, total and status. Pasting it yields a header row of those four names and one line per order. An order whose customer is recorded as Patel, Asha is written with quotes around the name, so the spreadsheet still shows four columns and the comma stays inside the value. An order with no status field shows an empty status cell, which the reader can treat as unknown. The file opens cleanly in Excel and can be re-imported with the same field names intact. When the data has to travel back the other way, the CSV to JSON converter makes the return trip, though every value will come back as a string.

Frequently asked questions

An array of objects, for example a list of records each with the same field names. A single object or an array of plain values is rejected because there are no keys to use as column headers.
The header row comes from the first object only. Any key that does not exist in that first object is ignored, even if later objects use it. Reorder the array or normalise the data so the first object has every field.
Yes. Fields containing a comma, a double quote or a line break are wrapped in quotes and internal quotes are doubled, following RFC 4180, so the columns stay aligned.
They are flattened into text, so a nested object appears as object Object. Flatten the JSON first if you need to keep those inner values as separate columns.