How to Convert JSON to CSV Without Losing Any Data
Spreadsheets don't understand nested JSON. This guide explains how a JSON array becomes clean, aligned CSV rows, and how to avoid the mistakes that corrupt spreadsheet imports.
Every analyst, ops engineer, and data importer eventually hits the same wall: an API or export gives you a JSON array, but the tool that actually needs the data - Excel, Google Sheets, a CRM bulk importer - only speaks CSV. The two formats look similar on the surface, but JSON supports nesting and arrays while CSV is strictly flat rows and columns. Converting between them means making real decisions about how to represent structure that spreadsheets were never designed to hold.
This guide walks through what actually happens during a JSON-to-CSV conversion - how headers get built, how nested objects and arrays are handled, and where naive conversions quietly break. You'll also see how to do it in seconds with the JSON to CSV Converter, which flattens, aligns, and escapes everything locally in your browser so exported records never touch a server.
What does converting JSON to CSV actually mean?
JSON represents data as a tree - objects can nest inside objects, and arrays can hold objects, strings, or numbers in any combination. CSV represents data as a grid - one header row of column names, followed by one row per record, with every row sharing exactly the same columns. Converting from JSON to CSV means taking an array of objects and reshaping that tree into a grid without silently dropping any values along the way.
The input to a JSON to CSV conversion is almost always an array of objects - think of it as a list of records, like rows returned from a database query or a paginated API response. Each object in the array becomes one row, and the keys inside those objects become the columns.
A JSON array becomes a CSV table
Object keys turn into the header row; each object becomes one row.
Input
[
{ "id": 1, "name": "Ada Lovelace", "role": "Engineer" },
{ "id": 2, "name": "Alan Turing", "role": "Mathematician" }
]Output
id,name,role
1,Ada Lovelace,Engineer
2,Alan Turing,MathematicianWhy you need a proper JSON to CSV workflow
It's tempting to think this is trivial - just print the values, comma-separated. In practice, real-world JSON is messy in ways that break that shortcut fast:
- Spreadsheets expect flat data. Analysts and finance teams live in Excel and Google Sheets, not JSON viewers - a clean CSV export means the data is immediately usable.
- Bulk importers require columns. CRMs, e-commerce platforms, and database loaders typically accept CSV, not raw JSON, for bulk record imports.
- Nested structure needs a decision. Address objects, tag arrays, and metadata blobs all need to become something a single cell can hold - and that decision has to be consistent across every row.
- Ragged records need alignment. Real API data is rarely uniform; some objects have optional fields the others don't, and every row still needs to line up under the same header.
How JSON to CSV conversion works under the hood
A solid converter runs through three passes over your array. First, it scans every object to build the header row as the union of all keys it finds - not just the keys in the first object. That single pass is what prevents columns from silently disappearing when later records introduce a field the first record didn't have.
Second, it flattens nested objects into dotted column names. A field like { "address": { "city": "Berlin" } } becomes a column literally named address.city, so the city ends up in its own cell instead of a chunk of raw JSON text jammed into one column. Nested arrays are handled differently: since CSV has no native way to represent a list inside a cell, arrays are serialized as a JSON string, e.g. "[1,2,3]", so the data survives even though it isn't further exploded into columns.
Third, it applies RFC 4180 quoting rules while writing the file. Any value containing a comma, a double quote, or a line break gets wrapped in double quotes, and embedded quotes are doubled (" becomes ""). Skip this step and a name like Smith, Jr. will silently split into two columns the moment Excel opens the file.
Where does your data go during conversion?
Parsing JSON, building headers, and writing quoted CSV rows are all pure computation - there's no reason any of it needs a server. The JSON to CSV Converter runs entirely in your browser, so customer records, order histories, or any other sensitive export never leaves your machine as plain text on the wire.
Step-by-step: turn a JSON array into CSV
- Open the JSON to CSV Converter and paste your JSON array - a list of objects, each one representing a row.
- Pick a delimiter if the default comma doesn't suit your locale or destination tool; semicolon and tab are common alternatives for regions and apps that treat the comma as a decimal separator.
- Review the generated header row. It's the union of every key found across all objects, including ones that only appear in a handful of records.
- Check that nested objects appear as dotted columns (like
address.city) and that any array fields were serialized rather than dropped. - Download the result as a
.csvfile, or copy it straight into Excel, Numbers, or Google Sheets.
That's the entire workflow - no account, no upload step, and no waiting on a server to process the file before you can download it.
Common use cases for JSON to CSV
- Exporting an API's JSON response so an analyst can pivot and chart it in a spreadsheet.
- Preparing JSON records for a bulk import into a CRM, e-commerce catalog, or database loader.
- Sharing structured data with non-technical stakeholders who live in Excel, not JSON viewers.
- Converting a JSON log dump into CSV rows so it can be filtered and summarized with pivot tables.
- Generating a CSV seed file from JSON test fixtures for QA or onboarding demos.
Common mistakes when converting JSON to CSV
Assuming every object has the same keys
Building the header from only the first object in the array is a classic bug - the moment record #47 has an extra discountCode field, that column either gets dropped or shifts every value after it out of alignment. A correct converter always unions keys across the whole array before writing the header.
Dumping nested JSON into one cell
Some quick scripts just call JSON.stringify() on a nested object and drop the whole blob into a single column. It technically preserves the data, but it defeats the point of exporting to CSV in the first place - nobody can filter or sort by address.city if it's buried inside a stringified object. Flattening nested fields into their own dotted columns, as described above, keeps every value queryable.
Unescaped commas, quotes, and line breaks
A value like "Product, Deluxe Edition" will silently split into two columns if it isn't wrapped in quotes. Multi-line text fields (like a customer comment) cause the same problem if embedded newlines aren't handled per RFC 4180. Always confirm the converter you're using quotes fields correctly rather than doing a naive comma-join.
Using the wrong delimiter for the destination locale
In several European locales, Excel expects a semicolon delimiter because the comma is already used as the decimal separator. A CSV that's perfectly valid by RFC 4180 can still open as one giant unsplit column in a misconfigured spreadsheet app if the delimiter doesn't match what that copy of Excel expects.
Best practices for reliable JSON to CSV exports
- Convert from an array of objects, not a single object or deeply mixed structure - each object should represent one logical row.
- Sanity-check the header row against a few sample records to confirm no optional field got missed before you import into a CRM or database.
- If you plan to re-import the CSV back into JSON later, keep a note of which columns were flattened so CSV to JSON can reconstruct nesting correctly.
- Pick your delimiter based on the destination app's locale, not just habit - test the first few rows after opening the file.
- For sensitive exports - customer PII, financial records, credentials - use a converter that runs locally instead of pasting the data into an online service that uploads it.
Tip
If your source JSON has deeply nested structures beyond one or two levels, running it through JSON Flatten first can make the resulting CSV columns more predictable before you convert to CSV.
Related tools
Parse CSV into a clean array of typed JSON objects, header-aware.
Flatten nested JSON into single-level dot-notation key paths.
Turn JSON into clean, readable YAML for configs, pipelines and manifests.
Pretty-print JSON with configurable indentation and instant validation.
Related guides
Turning a spreadsheet export into usable JSON is trickier than a simple comma split. This guide covers headers, quoting, delimiters and type inference, plus how to convert CSV safely in your browser.
Nested JSON is hard to drop into a spreadsheet, an .env file, or a flat key-value store. This guide explains how flattening converts nested structures into dot-notation keys, when to use it, and the mistakes to avoid.
Kubernetes, GitHub Actions and Ansible all expect YAML, but your data often starts life as JSON. Here's how the conversion works, where it trips people up, and how to do it privately in seconds.
Minified JSON is unreadable and hard to debug. This guide covers how JSON formatting works, when to use it, common mistakes, and how to pretty-print JSON without uploading it anywhere.