JSON to CSV: the complete guide
Everything about JSON, CSV, and the conversions between them — from the basics to the edge cases that break naive scripts.
What is JSON?
JSON (JavaScript Object Notation) is a lightweight text-based format for structured data, derived from JavaScript object syntax. It was popularised by Douglas Crockford in the early 2000s and standardised as RFC 8259 in 2017. Today it is the lingua franca of web APIs, mobile apps, configuration files, and inter-service communication.
A JSON document is built from two structures: a collection of name/value pairs (an object, written with curly braces) and an ordered list of values (an array, written with square brackets). Every value is one of: string, number, boolean, null, object, or array. This minimalism is what makes JSON easy to parse in every programming language and human-readable enough to inspect with the naked eye.
Example JSON object:
{
"id": 42,
"name": "Alice Chen",
"email": "alice@example.com",
"skills": ["SQL", "Python", "Go"],
"address": { "city": "New York", "country": "US" },
"active": true,
"joined": 1672531200
}
The hierarchical nature of JSON — objects inside objects, arrays of objects, arrays of primitives — is what makes it powerful for representing real-world data, but it is also the main challenge when you want to put that data into a flat spreadsheet.
What is CSV?
CSV (Comma-Separated Values) is the oldest and most widely supported tabular data format. It predates JSON by decades and is defined loosely — the closest thing to a formal spec is RFC 4180 from 2005. A CSV file is plain text: one record per line, with each field separated by a delimiter (usually a comma, but tab, semicolon, and pipe are common).
Example CSV:
id,name,email,active
42,Alice Chen,alice@example.com,true
43,Bob Singh,bob@example.com,false
CSV's strengths are its simplicity and its universal compatibility. Every spreadsheet program (Excel, Google Sheets, Numbers, LibreOffice Calc), every database (Postgres, MySQL, SQLite, BigQuery, Snowflake), and every data tool (Pandas, R, Tableau, Power BI) can read CSV without additional libraries. The downside is that CSV cannot represent nested data, and the lack of a single formal spec means dialects vary — especially around quoting, escaping, and which characters are valid delimiters.
The most common dialects you'll encounter:
- RFC 4180 (Excel default): Comma delimiter, double-quote quoting, CRLF line endings, header row.
- Tab-separated (TSV): Tab delimiter, used by database exports and Excel paste-buffer.
- European CSV: Semicolon delimiter, because comma is the decimal separator in many EU locales.
- Pipe-separated (PSV): Pipe delimiter, used by log files and tools that need a delimiter unlikely to appear in data.
When should you convert JSON to CSV?
JSON to CSV is the right tool whenever you need to take data from a system that emits JSON and put it somewhere that wants a table. The most common scenarios:
- API analysis: Pull a REST API response, paste it into the converter, and open the result in Excel for ad-hoc analysis.
- Database ingestion: Many warehouses and databases accept CSV more readily than JSON, especially for one-time bulk loads.
- Reporting: Stakeholders who live in spreadsheets need CSV, not JSON.
- Data archival: CSV is more compact than JSON and is supported by long-term archival tools.
- Configuration migration: Some legacy systems only accept CSV imports.
The reverse — CSV to JSON — is just as common, especially when you're piping a spreadsheet into an API or a NoSQL database like MongoDB.
Common edge cases (and how to handle them)
Real-world JSON is messy. Here are the most common conversion pitfalls and how to handle each:
- Nested objects: Flattened with a separator.
{"address": {"city": "NYC"}}becomes the columnaddress__city. The separator is configurable. - Arrays of primitives: Joined with a delimiter.
["SQL", "Python"]becomesSQL | Python. Useful for tags, skills, and categories. - Arrays of objects (header/detail): One row per array element, with the parent fields duplicated. This is the default and works for most API responses with line-item data.
- Inconsistent keys across rows: The union of all keys is used for the column set; missing values become empty cells.
- Special characters in values: Commas, quotes, and newlines trigger automatic RFC-4180-style escaping. The cell is wrapped in double quotes and any embedded quote is doubled.
- Epoch timestamps: Optionally converted to ISO-8601 dates (
yyyy-mm-dd) for easier reading in Excel. - JSON Lines (one object per line): Detected and split into rows. Useful for log files.
- Top-level single object (not an array): Treated as a one-row CSV.
Best practices for JSON to CSV conversion
- Always use a header row. It documents your columns and makes downstream tools (Pandas, BigQuery, Excel) work correctly. Always emit a header row.
- Pick the right delimiter for your data. If your values contain commas, use tab or pipe. If your tool expects a specific delimiter (e.g., semicolon for EU Excel), use that.
- Be deliberate about nested data. There is no single "right" way to flatten a hierarchy into a table. The header/detail strategy works for most cases, but flattened or matrix modes may suit your analysis better.
- Convert dates to ISO-8601. Excel often mis-parses local date strings.
2024-12-31is safer than12/31/2024. - Spot-check the output. Open the first 5–10 rows in Excel and verify the structure before committing to a full download.
- Use UTF-8 encoding. Always emit UTF-8. If a downstream tool doesn't recognise it, open the CSV in a text editor and re-save with the right BOM.
HopConvert vs other JSON to CSV tools
There are dozens of JSON to CSV converters online. Here's how HopConvert compares on the dimensions that matter:
- Privacy: HopConvert runs entirely in your browser. Other tools often upload your data to a server — fine for public APIs, risky for sensitive data.
- Cost: HopConvert is free, with no sign-up, no limits, and no premium tier.
- Nested data: HopConvert offers four strategies. Many competitors offer only one (usually flattened), which produces ugly output for the common header/detail case.
- Live preview: HopConvert shows the result table as you type. Most other tools require you to click "Convert" first.
- Settings: Custom delimiters, epoch conversion, smart column ordering — all available without an account.
For quick, one-off conversions of non-sensitive data, any tool will do. For repeated use on real data — APIs, exports, logs — the privacy and depth of HopConvert make a real difference.
The same job, the way you need it
Free tools for the specific version of this conversion you are actually doing.
JSON to CSV in Python
The csv.DictWriter code for the same job, with a worked example you can copy.
JSON array to CSV
One array of objects in, a flat table out - with the jq one-liner.
JSON to CSV with nested objects
Four flattening strategies, and what each one is actually good for.
JSON to CSV without uploading
Convert sensitive payloads in your browser, with a request log you can check.
JSON to CSV for Excel
The encoding and delimiter details that make a CSV open cleanly in Excel.
Frequently asked questions
What is a JSON to CSV converter?
Is JSON to CSV conversion free?
Does the converter handle nested JSON?
address__city), concatenated (arrays joined with a delimiter), and matrix (full Cartesian expansion). The default header/detail mode works for most API responses.Which delimiters are supported?
Is my data private?
Try the JSON to CSV converter
Free, instant, and private — your JSON never leaves this tab.