Skip to main content
ToolsHub
5 min read

How to Convert JSON to CSV (Nested Objects, Arrays)

Turn JSON arrays into clean CSV files: flatten nested objects, handle arrays, and avoid the UTF-8 BOM and separator gotchas that break Excel imports.

When You Need JSON as a Spreadsheet

JSON is the language of web APIs, but spreadsheets still rule the business world. When a colleague asks for "the data in Excel," they rarely want a raw API payload — they want neat rows and columns they can sort and filter. Converting JSON to CSV bridges that gap. A CSV file (comma-separated values) is plain text where each line is a row and each value is separated by a delimiter. It is the universal interchange format that Excel, Google Sheets, Numbers, and every database can import. The challenge is that JSON is hierarchical — objects inside objects, arrays inside arrays — while CSV is strictly flat. The conversion is really a flattening exercise. The JSON to CSV converter runs entirely in your browser, so your data never leaves your machine. That matters when the JSON contains customer records or anything you would not paste into a random website. The payoff is large: once the data sits in a spreadsheet, non-technical colleagues can sort, filter, chart, and pivot it without touching code, which is usually the real reason the export was requested in the first place.

Flattening Nested Objects

CSV has no concept of nesting, so a nested object must be expanded into multiple columns. The common convention is dot notation: a field like address.city becomes its own column header, and the value is pulled from the nested object. Consider this record: { "name": "Alice", "address": { "city": "Leeds", "zip": "LS1" } } A good converter turns that into three columns — name, address.city, and address.zip — with the matching values on each row. Deeply nested data simply produces longer header names like billing.contact.email. Before you flatten anything, it pays to make sure the JSON is actually valid. Paste it into the JSON formatter first: a single trailing comma or unquoted key will stop any converter cold, and the formatter pinpoints the exact line so you can fix the source.

Dealing with Arrays

Arrays are the trickiest part of JSON-to-CSV conversion because there are two very different cases. The first case is the top-level array — a list of records. This is the ideal input: each object becomes one row, and the union of all keys becomes the header. Most converters expect this shape. The second case is an array nested inside a record, such as a list of tags or order line items. There is no single correct answer here. You can join the values into one cell ("red; green; blue"), spread them across numbered columns (tags.0, tags.1, tags.2), or explode each array element into its own row. Decide based on how the spreadsheet will be used: joining is best for human reading, while one-row-per-element is best for pivot tables. If your source is YAML rather than JSON, convert it first with the YAML to JSON converter, then flatten the resulting JSON the same way.

Excel Import Gotchas (BOM and Separators)

A technically perfect CSV can still look broken when Excel opens it. Two issues cause most of the pain. The UTF-8 BOM. Excel on Windows often assumes a legacy encoding, so accented characters and emoji turn into garbled text. Adding a UTF-8 byte order mark (BOM) — three invisible bytes at the start of the file — tells Excel to read it as UTF-8. Most quality converters offer an "add BOM" option for exactly this reason. The separator. In many European locales Excel expects a semicolon, not a comma, because the comma is the decimal separator. Open a comma CSV in such a locale and everything lands in one column. The fix is to either choose a semicolon delimiter when exporting or use the Excel Data import wizard, which lets you pick the delimiter explicitly. Quoting. Any value that itself contains the delimiter, a quote, or a line break must be wrapped in double quotes, with internal quotes doubled. A good converter handles this automatically — verify by opening the result and checking that addresses with commas stay in one cell. Follow these steps for a clean import: 1. Validate the JSON, then run it through the converter. 2. Choose your delimiter to match your locale. 3. Enable the UTF-8 BOM if you see garbled characters. 4. Open the file and confirm columns and accents look right.

Frequently Asked Questions

Does converting JSON to CSV lose data?

It can. CSV is flat, so nested arrays must be joined, spread, or exploded into rows, and any of those choices simplifies the structure. Keep the original JSON if you may need the full hierarchy later.

Why are accented characters garbled when I open the CSV in Excel?

Excel on Windows often assumes a non-UTF-8 encoding. Export the file with a UTF-8 byte order mark (BOM), or use the Data import wizard and set the encoding to UTF-8 manually.

My whole row appears in one cell — what went wrong?

Your locale expects a different delimiter. Many European versions of Excel use a semicolon rather than a comma, so export with a semicolon or use the import wizard to select the comma delimiter.

Is my data uploaded anywhere during conversion?

No. The converter processes everything locally in your browser using JavaScript, so the JSON and resulting CSV never reach a server. It is safe for sensitive records, though you should still avoid pasting production secrets.