JSON ↔ CSV Converter
Convert a JSON array of objects to CSV, or parse CSV into a JSON array. Handles quoting and headers automatically.
About JSON ↔ CSV Converter
This converter translates between a JSON array of flat objects and CSV (comma-separated values). When converting JSON → CSV, the union of all object keys becomes the header row, and each object becomes one data row. When converting CSV → JSON, the first row is treated as the header and each subsequent row becomes an object. Quoting and escaping follow RFC 4180.
When to use it
- Importing API data into Excel, Google Sheets, or a database that accepts CSV
- Exporting a CSV from a legacy system into a format your app can consume
- Generating CSV reports from a fetched API response without writing code
- Converting tabular JSON into a form that paginates nicely as a spreadsheet
- Bulk-loading data for testing or seeding
How it works
JSON → CSV: the array is iterated to compute the union of all keys (preserving first-seen order), which becomes the header. Each value is stringified — objects and arrays as JSON, null/undefined as empty, primitives as their string form. Fields containing commas, quotes, or newlines are wrapped in double quotes, and embedded double quotes are doubled, per RFC 4180. CSV → JSON: a stateful parser handles quoted and unquoted fields, doubled-quote escapes, and both LF and CRLF line endings.
Examples
[
{"name": "Ada", "role": "engineer"},
{"name": "Grace", "role": "admiral"}
]name,role Ada,engineer Grace,admiral
id,product,price 1,Widget,9.99 2,"Gadget, Pro",19.50
[
{
"id": "1",
"product": "Widget",
"price": "9.99"
},
{
"id": "2",
"product": "Gadget, Pro",
"price": "19.50"
}
]Frequently asked questions
- Does it handle nested objects?
- Nested objects and arrays are stringified as JSON within their CSV cell. That keeps the round-trip lossless but means the CSV won't open cleanly in Excel — spreadsheet tools expect flat tabular data.
- Are CSV values typed?
- CSV has no native type system, so CSV → JSON produces all-string values. If you need typed JSON, post-process with a schema or write a small mapping step.
- What about commas and quotes in cells?
- Per RFC 4180, fields containing commas, double quotes, or newlines are wrapped in double quotes, and embedded quotes are doubled (""). The parser also handles these correctly.
- Does this support semicolon-separated CSV?
- This tool uses a comma. If your locale uses semicolons (common in parts of Europe), do a find-and-replace first, or use the JSON ↔ TSV tool as a model for custom delimiters.
- Are line endings preserved?
- The output uses LF (\n) line endings. Most modern tools accept either LF or CRLF; if you need CRLF specifically (older Excel versions), post-process the output.