About JSON to CSV
JSON is how APIs speak; CSV is how spreadsheets, BI tools, and data teams work. Converting between them is one of the most common data chores there is: exporting an API response for a colleague to open in Excel, loading records into Google Sheets, or preparing a quick dataset for a pivot table. This tool converts a JSON array of objects into CSV (RFC 4180 style) directly in your browser.
The ideal input is an array of flat objects — each object becomes a row, each key becomes a column. Real-world JSON is rarely that tidy, so it helps to understand exactly how nested data, missing keys, and special characters are handled before you trust the output in a report.
How to use JSON to CSV
- Paste your JSON (array of objects or single object) in the input area.
- Click Convert to generate CSV with headers from object keys.
- Copy or download the CSV output.
Example
Input
[{"name":"Alice","age":30},{"name":"Bob","age":25}]Output
name,age Alice,30 Bob,25
How the conversion maps JSON to rows and columns
The converter scans the array and collects the union of all keys across all objects to build the header row. Every object then becomes one row, with empty cells for keys it does not have. This union behavior matters with heterogeneous data: if one record out of a thousand has an extra field, you get an extra, mostly-empty column — a useful signal that your records are not uniform.
Values are quoted according to CSV rules: any field containing a comma, a double quote, or a line break is wrapped in double quotes, and embedded quotes are doubled (" becomes ""). Numbers and booleans are written literally. Null and undefined become empty cells.
Nested objects and arrays — the part that always surprises people
CSV is flat; JSON is a tree. When a value is itself an object or array ({"user": {"name": "a"}}), there is no lossless flat representation, so nested values are serialized as JSON strings inside the cell. That is correct but often not what a spreadsheet user wants.
If you need real columns like user.name and user.email, flatten the structure first: run the data through the JSON Flattener tool (which converts nesting into dot-path keys), then convert to CSV. The two-step pipeline gives you clean columns without writing any code.
Excel gotchas worth knowing
Most 'the CSV is broken' reports are actually spreadsheet import behavior:
- Leading zeros disappear: Excel parses 00420 as the number 420. Import the column as text, or prefix values in the source data.
- Long numbers are mangled: values over 15 digits (card numbers, snowflake IDs) get rounded and displayed in scientific notation. Keep them as text.
- Dates auto-convert: strings like 2024-01-02 or 1/2 may become dates, notoriously corrupting things like gene names. Use Excel's import wizard with explicit column types.
- Formula injection: a cell starting with =, +, -, or @ can execute as a formula when opened — a real security issue if the JSON contains user-generated content. Sanitize such data before distributing CSV files.
- Encoding: this tool outputs UTF-8. Old Excel versions may need a BOM to show non-ASCII characters correctly; modern Excel and Google Sheets handle UTF-8 fine.
Common errors and how to fix them
"Input must be a JSON array" (or only one row appears)
Cause: The top level of your JSON is an object, not an array — often the array is nested under a key like data or results.
Fix: Extract the array first, e.g. paste the value of data. The JSON Path Extractor tool can pull it out with a path like data.
Columns appear in unexpected order or extra columns show up
Cause: Headers are the union of keys across all records; records with rare fields add columns.
Fix: Confirm the extra columns are legitimate. If records should be uniform, the extra column names tell you which records deviate.
Cells contain raw JSON like {"city":"Paris"}
Cause: The source objects are nested; CSV cannot represent trees.
Fix: Flatten with the JSON Flattener first (user.city becomes its own column), then convert.
Values split across columns after opening in a spreadsheet
Cause: The spreadsheet was told to split on a different delimiter (e.g. semicolon locales) or the file was opened without an import dialog.
Fix: Use the import wizard and select comma as delimiter and UTF-8 as encoding, rather than double-clicking the file.
Tips and best practices
- Pipeline for nested data: JSON Flattener → JSON to CSV. It handles the two hardest problems (nesting and naming) in one pass.
- Sort keys first (JSON Sort Keys tool) if you want deterministic column order across exports.
- For huge exports, prefer NDJSON on the API side and convert in batches — browsers handle 10 MB comfortably, but a 500 MB export belongs in a script (jq -r or pandas).
- If the CSV will be shared publicly and contains user input, neutralize formula injection by prefixing risky cells with a single quote.
Frequently asked questions
- What input shape does the converter expect?
- A JSON array of objects: [{"a":1},{"a":2}]. Each object becomes a row. A single object works too (one row). If your array is wrapped in an envelope like {"data": [...]}, extract it first.
- How are missing keys handled?
- The header is the union of all keys in all records; a record without a key gets an empty cell in that column. This is lossless in the row direction but makes ragged data visible as sparse columns.
- How are nested objects converted?
- They are serialized as JSON strings inside the cell, because CSV has no native nesting. For real columns per nested field, flatten the JSON first with the JSON Flattener tool.
- Does the output follow a standard?
- It follows RFC 4180 conventions: comma delimiter, double-quote quoting, quotes escaped by doubling, and rows separated by line breaks. This imports cleanly into Excel, Google Sheets, pandas, and every mainstream database loader.
- Why do my big numeric IDs look wrong in Excel?
- Excel stores numbers as floating point with 15 significant digits; longer IDs get rounded. The CSV itself is correct — import that column as text, or convert IDs to strings before export.
- Is my data private?
- Yes. The conversion runs entirely in your browser; nothing is uploaded.
Embed this tool
Add JSON to CSV to your own site, blog post, or internal docs — free, no signup. The widget runs entirely in your visitors' browsers, same as it does here.
Related tools
- JSON FormatterFormat and beautify JSON with indentation
- JSON ValidatorValidate JSON syntax and show error location
- JSON MinifierRemove whitespace and compress JSON
- JSON DiffCompare two JSON objects and highlight differences
- JSON ViewerInteractive tree and graph visualization of JSON structure
- JSON to YAMLConvert JSON to YAML format