Tutorial · 5 min read
How to Convert Nested JSON to CSV in Excel
JSON APIs almost never return flat data. You get objects inside objects, arrays of nested items, and deeply buried fields. Before you can work with that data in Excel or Google Sheets, you need to flatten it into a clean CSV. This guide covers three flattening modes and how to use our JSON to CSV converter to get results in seconds.
The Problem with Nested JSON
A typical API response looks like this — easy to read in JSON, but impossible to paste directly into a spreadsheet:
[
{
"name": "Alice",
"contact": {
"email": "alice@example.com",
"phone": "123-456-7890"
},
"address": {
"city": "Beijing",
"district": "Haidian"
}
},
{
"name": "Bob",
"contact": {
"email": "bob@example.com"
},
"address": {
"city": "Shanghai",
"district": "Pudong"
}
}
]
CSV only supports flat rows and columns. To convert this, you need to flatten the nested fields into separate columns — and that's exactly what a free JSON to CSV tool does automatically.
1. Dot-Separated Flattening (Default)
This is the most common mode. Nested keys become dot-separated column headers:
| name | contact.email | contact.phone | address.city | address.district |
|---|---|---|---|---|
| Alice | alice@example.com | 123-456-7890 | Beijing | Haidian |
| Bob | bob@example.com | Shanghai | Pudong |
Best for: data analysis, database import, and spreadsheet work. Try it with the converter — it's the default mode and works out of the box.
2. JSON String Mode (Preserve Structure)
Sometimes you want to keep the nested structure intact. In this mode, nested objects are kept as JSON strings in a single cell:
| name | contact | address |
|---|---|---|
| Alice | {"email":"alice@example.com","phone":"123-456-7890"} | {"city":"Beijing","district":"Haidian"} |
| Bob | {"email":"bob@example.com"} | {"city":"Shanghai","district":"Pudong"} |
Best for: when you need the original structure for reference, or when the nested data will be processed by another script later.
3. 1-Level Only Mode (Shallow Flatten)
A middle ground — flatten only the first level of nesting, keep deeper levels as JSON strings:
| name | contact | address.city | address.district |
|---|---|---|---|
| Alice | {"email":"alice@example.com","phone":"..."} | Beijing | Haidian |
Best for: when only the top-level nesting matters and deeper details can remain as JSON strings.
4. Handling API-Wrapped Responses
Most APIs wrap their data in an outer object with metadata. The actual array is buried inside:
{
"status": "ok",
"count": 2,
"data": {
"users": [
{ "id": 1, "name": "Alice" },
{ "id": 2, "name": "Bob" }
]
}
}
Fix: Use the JSON Path feature in the tool. Simply enter data.users as the path, and the converter extracts that specific array for conversion.
Try the Free JSON to CSV Converter
Paste nested JSON and see it flattened instantly. Edit cells, choose output format, and download clean CSV.
Convert JSON to CSV Now →Best Practices for JSON to CSV Conversion
- Start with Dot-Separated mode. It works for 90% of use cases. Switch modes only if columns get too complex.
- Use JSON Path for API responses. If your JSON has a wrapper like
{"data": {"items": [...]}}, use JSON Path to extract the right array. - Repair before converting. If the JSON is broken (trailing commas, missing brackets), fix it first with our JSON Repair guide.
- Check Excel encoding. Use UTF-8 BOM encoding when exporting CSV for Excel to avoid garbled text.
- Review the table preview first. The live preview shows exactly how your CSV will look — check for missing columns or unexpected nulls before downloading.
Frequently Asked Questions
How do I convert nested JSON to CSV online?
Paste your nested JSON into the JSON to CSV Converter. The tool automatically flattens nested objects using dot notation (e.g., address.city). Choose between Dot-Separated, JSON String, or 1-Level mode in the configuration bar.
What is the best flattening mode for nested JSON?
Dot-Separated mode is the default and works for most cases. Use JSON String mode if you need to preserve the original structure. Use 1-Level mode when only the first nesting level matters. Experiment by switching modes — the table preview updates instantly so you can see the result before exporting.
How do I handle API-wrapped JSON responses?
API responses often wrap arrays in objects like {"data": {"items": [...]}}. Use the JSON Path input to specify the path, e.g., data.items. The tool will extract that specific array for conversion.
Can I edit the data before exporting to CSV?
Yes — the table preview is fully editable. Double-click any cell to modify its value. You can also sort columns, hide columns, insert or delete rows, and undo changes. All edits are included in the final CSV export.
Why is my CSV showing garbled text in Excel?
This happens when Excel misinterprets the character encoding. In the tool's config bar, switch encoding to UTF-8 BOM and line endings to CRLF. For best results, download as .xlsx format directly instead.
Is my JSON data safe with this converter?
100% safe. All processing happens in your browser. Your JSON data is never uploaded to any server, stored, or tracked. The tool works offline once loaded — your data never leaves your computer.