How to Convert JSON to CSV (and Open It in Excel)

Converting JSON to CSV sounds trivial: JSON is a list of records, CSV is rows and columns, done. It stays trivial right up until the JSON has a nested object or an array inside a record, which is when a naive conversion produces a column full of [object Object] or a mangled mess. This guide covers the clean way to flatten JSON to CSV, how to open the result in Excel and Google Sheets, and the gotchas (row limits, encoding, nested data) that trip people up.

Why nested JSON is the hard part

A CSV is strictly two-dimensional: one header row, then flat rows of values. JSON is a tree. The conversion is only clean when your JSON is a flat array of objects with the same keys:

[
  { "id": 1, "name": "Ada",   "city": "London" },
  { "id": 2, "name": "Grace", "city": "New York" }
]

That becomes exactly what you expect:

id,name,city
1,Ada,London
2,Grace,New York

The trouble starts when a value is itself an object or an array, for example "address": { "city": "London", "zip": "SW1A" }. CSV has no cell type for that, so a converter has to either flatten it into new columns (address.city, address.zip) or serialize it back to a string. Flattening is almost always what you want, and it is the single most important thing a good converter does for you.

The fastest route: a browser converter

For a one-off conversion, an online tool is quicker than writing code or wrestling with Excel. Paste the JSON into the JSON to CSV converter, and it flattens nested objects into dotted columns, expands arrays, and hands back CSV you can download or copy straight into a spreadsheet. Because it runs in your browser, the data is not uploaded anywhere, which matters when the payload came from a production API.

If the JSON will not convert at all, it is usually invalid rather than just complex. Run it through the JSON parser first to find the exact syntax error, or format it so you can see the structure before you convert. For a deeply nested payload, expanding it in the JSON viewer first makes it obvious which fields will become their own columns and which are arrays you will need to expand.

Opening the CSV in Excel

Once you have the CSV, there are two ways into Excel, and the difference matters.

The quick way (double-click). Save the file with a .csv extension and open it. This works for simple data, but Excel guesses at delimiters and encodings, and it will happily turn 007 into 7 or a long number into scientific notation.

The reliable way (Power Query). In Excel, go to Data → Get Data → From File → From JSON, and you can skip CSV entirely: Power Query imports the JSON, lets you expand nested records into columns visually, and loads a proper table. This is the best route for messy or nested JSON because you control how each level is flattened before anything lands in the sheet. Google Sheets users can do the equivalent with File → Import on the CSV, choosing UTF-8 and comma-separated.

The gotchas that bite

A few things go wrong often enough to plan for:

Doing it in code

If this is a repeatable job, script it. In Python the standard library covers the flat case:

import json, csv

with open("data.json") as f:
    rows = json.load(f)

with open("out.csv", "w", newline="") as f:
    writer = csv.DictWriter(f, fieldnames=rows[0].keys())
    writer.writeheader()
    writer.writerows(rows)

That works only when every record is flat and shares the same keys. For nested JSON, flatten each record first (for example with pandas.json_normalize, which turns address.city into its own column) before writing the CSV. For a one-time conversion, though, the browser converter does the flattening for you with nothing to install.

If you are new to the format underneath all this, the guide on what JSON is covers its structure and data types, and the roundup of free JSON tools points to the rest of the toolkit for formatting, validating, and comparing JSON.

Frequently asked questions

How do I convert nested JSON to CSV?
Flatten it first. Nested objects become dotted columns (address.city), and arrays are expanded or split. The JSON to CSV tool does this automatically; in code, pandas.json_normalize is the usual approach.

Why does Excel show [object Object] in a column?
The JSON had a nested object in that field and the converter serialized it instead of flattening it. Use a converter that expands nested objects into separate columns, or flatten the data before export.

What is the maximum number of rows Excel can open?
1,048,576 rows per worksheet. Larger CSVs are truncated on open, so use a database or a data tool for anything bigger.

Can I convert JSON to CSV without uploading my data?
Yes. The JSON to CSV converter runs entirely in your browser, so the JSON never leaves your machine.

How do I keep leading zeros and long IDs?
Import the column as Text (in Excel’s Power Query or Google Sheets’ import dialog) so the spreadsheet does not treat it as a number and strip zeros or round it.

Leave a Reply

Your email address will not be published. Required fields are marked *