JSON to CSV
Convert a JSON array of objects to CSV. Keys become column headers.
Turning JSON into a spreadsheet
APIs return JSON; the people who need the data usually want a spreadsheet. This converter takes a JSON array of objects, uses the keys as column headers, and writes one row per object.
The conversion is straightforward when the data is flat and rectangular. It gets interesting when the JSON is nested or ragged, which real API responses usually are.
Key takeaways
- Input must be an array of objects, not a single object or a bare value.
- Object keys become the column headers.
- Fields containing commas, quotes or newlines are automatically quoted.
- Nested objects and arrays have no natural CSV representation and must be flattened.
- Excel needs a UTF-8 BOM to display accented characters correctly.
How the conversion works
[
{"name": "Ada", "age": 36},
{"name": "Grace", "age": 45}
]
CSV output:
name,age
Ada,36
Grace,45
Escaping rules applied
| Value | Written as | Why |
|---|---|---|
| Smith, John | "Smith, John" | Contains the delimiter |
| She said "hi" | "She said ""hi""" | Quotes doubled and field wrapped |
| line one\nline two | "line one[newline]line two" | Contains a line break |
| plain | plain | No special characters, no quoting needed |
| null | (empty) | Null becomes an empty field |
The nesting problem
CSV is a flat, rectangular format. JSON is a tree. There is no lossless way to express a tree in a table, so nested data must be flattened - and every flattening strategy loses something.
| Strategy | Example | Trade-off |
|---|---|---|
| Dot-path columns | user.address.city | Clear, but produces very wide files |
| JSON-encode the value | {"city":"London"} | Lossless but unreadable in a spreadsheet |
| Take one row per array item | Repeats parent data on each row | Denormalizes; row counts multiply |
| Drop nested fields | Ignore them entirely | Simple, and loses data silently |
Dot-path flattening is usually the most practical for a human-readable export. For machine round-tripping, keep the JSON.
Opening the result in Excel
- Accented characters look wrong unless the file starts with a UTF-8 byte order mark. Excel assumes the system codepage otherwise.
- Leading zeros disappear - Excel converts 007 to 7 on import. Import as text, or prefix values with an apostrophe.
- Long numbers become scientific notation. A 16-digit ID displays as 1.23457E+15 and, worse, loses precision permanently once saved.
- Date-like strings get reformatted according to local settings, so 2026-09-14 may become 14/09/2026 or worse.
- Use Data to From Text/CSV rather than double-clicking the file. The import wizard lets you set column types explicitly.
When CSV is the wrong choice
- Deeply nested data - keep it as JSON, or use a format that supports structure.
- Data with mixed types per column - CSV has no way to express that.
- Very large datasets - Parquet or a database is far more efficient.
- Data that round-trips programmatically - CSV loses type information every time.
- Anything with a schema you need to enforce - CSV has no schema at all.
CSV is best understood as an interchange format for humans and spreadsheets, not as a storage format for applications.
Frequently Asked Questions
How do I convert JSON to CSV?
Paste a JSON array of objects into the tool. The object keys become column headers and each object becomes a row, with fields escaped correctly where they contain commas, quotes or line breaks.
What JSON structure does it need?
An array of objects, such as [{"a":1},{"a":2}]. A single object or a bare value has no rows to write. If your API wraps the data in an envelope, extract the array first.
How are nested objects handled?
They have to be flattened, because CSV is a flat rectangular format and JSON is a tree. Common approaches are dot-path column names like user.address.city, or JSON-encoding the nested value into a single cell. Every approach loses something.
What happens if objects have different fields?
The CSV needs a column for every field that appears anywhere in the array, with empty values where an object lacked it. Taking headers from only the first object silently drops fields that appear later - a bug worth checking for.
Why do accented characters look wrong in Excel?
Because Excel assumes the system codepage unless the file begins with a UTF-8 byte order mark. Adding a BOM, or using Data then From Text/CSV and selecting UTF-8 explicitly, fixes it.
Why does Excel change my numbers and dates?
Excel aggressively infers types on import. It strips leading zeros, converts long numbers to scientific notation with permanent precision loss, and reformats anything that looks like a date. Use the import wizard and set the affected columns to Text.
How are null values written?
As empty fields. There is no way to distinguish null from an empty string in CSV, which is one of the format's inherent limitations - the information is simply lost.
Is my data sent to a server?
No. Conversion happens entirely in your browser and nothing is uploaded or stored, which matters when the JSON contains real API responses or customer data.