JSON to CSV (and Back): Converting Data Cleanly
JSON and CSV are the two formats most data lives in: JSON for APIs and code, CSV for spreadsheets and anyone who’d rather open it in Excel. Moving between them is a constant chore, and doing it by hand is where commas and quotes go wrong. The JSON to CSV Converter does it both ways in your browser; this guide explains exactly what maps to what and the gotchas to watch.
What maps to what
The clean mental model is simple:
- A JSON array of objects becomes CSV rows.
- Each object is one row.
- The object keys become the column headers.
So this JSON:
[{ "name": "Ann", "age": 30 }, { "name": "Ben", "age": 25 }]
becomes this CSV:
name,age
Ann,30
Ben,25
Going the other way, CSV → JSON, the header row becomes the keys and each subsequent row becomes an object.
The gotchas that break naive conversions
This is why a hand-rolled split won’t cut it:
- Commas inside values.
"Smith, Ann"must be wrapped in quotes in CSV ("Smith, Ann") or the column count breaks. A proper converter quotes any value containing a comma, quote, or line break. - Quotes inside values. A
"inside a field is escaped by doubling it ("") in CSV. Parsing back,""becomes a single". - Uneven keys. If one object has a
phonefield and another doesn’t, CSV still needs a column for it: the missing cells are just left blank. The converter collects the union of all keys for the header. - Nested objects and arrays. CSV is flat, so a nested value (
{"address": {...}}) can’t become a single cell cleanly. The converter serializes nested values to a JSON string in that cell so nothing is lost.
The JSON to CSV Converter handles all of these, so the round trip survives messy real-world data.
When to use each format
- Use CSV when the data is going to a spreadsheet, a non-developer, or a bulk import (Excel, Google Sheets, a CRM upload).
- Use JSON when it’s going to an API, a config, or code: anything that needs nested structure and types.
How to convert
- Open the JSON to CSV Converter.
- Pick the direction: JSON → CSV or CSV → JSON.
- Paste your data; the converted output appears instantly.
- Copy it, or download the file. For pretty-printing the JSON side first, the JSON Formatter helps.
FAQ
What JSON shape do I need for CSV?
An array of objects: [{...}, {...}]. Each object is a row and its keys are the columns. A single object is treated as a one-row table.
How are commas inside values handled?
They’re preserved by wrapping the value in double quotes in the CSV, and parsed back correctly when going from CSV to JSON. You never lose or split a value.
What happens to nested objects?
CSV is flat, so nested objects and arrays are stored as a JSON string in that cell. The data is preserved; it just isn’t broken into more columns.
Can I open the result in Excel?
Yes. The CSV uses a standard header row and comma delimiter, so it opens directly in Excel, Google Sheets, and Numbers.
Is my data uploaded?
No. The conversion runs entirely in your browser: nothing is sent to a server and there’s no signup.
Need to get an API response into a spreadsheet, or a spreadsheet into your code? Paste it into the JSON to CSV Converter pick the direction, and copy the clean result: commas, quotes, and uneven keys all handled.