[JSONZen]
Sign up and get Pro free for 3 months — no card required.Claim it →

Conversion guide

JSON to CSV: Convert Flat and Nested Data

How to convert JSON to CSV including nested arrays and objects. Side-by-side examples, common pitfalls, and a free in-browser tool that handles edge cases.

You have an API response or log dump in JSON, and you need it as a CSV for a spreadsheet, BI tool, or coworker who lives in Excel. Converting JSON to CSV is straightforward when the data is a flat array of objects, but nested arrays, mixed schemas, and missing fields break naive converters. This guide shows the fastest correct path and explains what each step actually does.

Drop your data into the JSON to CSV converter to skip the work — everything below explains what the tool does so you can debug your own data when something goes wrong.

TL;DR

A clean JSON to CSV conversion is three steps: load an array of objects, collect every unique key as a header, then write one row per object with values in header order. Nested objects flatten with dotted keys (user.email); nested arrays expand into either indexed keys (tags.0, tags.1) or one row per element, depending on the shape you want.

Step 1 — Start with an array of objects

CSV is a table. JSON has to look like a table before it can become one. The canonical input is a flat array of objects with consistent keys.

Input

[
  { "id": 1, "name": "Otter", "role": "engineer" },
  { "id": 2, "name": "Hawk", "role": "analyst" },
  { "id": 3, "name": "Lynx", "role": "admin" }
]

Output

id,name,role
1,Otter,engineer
2,Hawk,analyst
3,Lynx,admin

Headers come from the union of keys across all rows — so a row missing role still gets an empty cell, not a shifted column. Cells with commas, quotes, or newlines get wrapped in double quotes, with internal quotes doubled.

Step 2 — Flatten nested objects

Nested objects don't fit in one CSV cell. The standard convention is dot notation: user.email, address.city. This keeps every leaf value addressable from a single header.

Input

[
  {
    "id": 1,
    "user": { "name": "Otter", "email": "otter@example.com" },
    "address": { "city": "Springfield", "zip": "00000" }
  }
]

Output

id,user.name,user.email,address.city,address.zip
1,Otter,otter@example.com,Springfield,00000

If you need to inspect the flat shape before converting, use the JSON flatten tool on the source first — it's the same dotted-key convention.

Step 3 — Decide how to handle arrays

Nested arrays are where most converters fail. There are two reasonable strategies, and the right choice depends on what you'll do with the CSV.

Strategy A: indexed keys (one row per record)

Best when arrays are short and bounded.

[{ "id": 1, "tags": ["admin", "billing"] }]
id,tags.0,tags.1
1,admin,billing

Predictable headers, one row per source record. Loses meaning when arrays vary in length across records.

Strategy B: explode (one row per array element)

Best when the array represents multiple entities — like order line items.

[
  {
    "order": "ord_A100",
    "items": [
      { "sku": "widget", "qty": 2 },
      { "sku": "gadget", "qty": 5 }
    ]
  }
]
order,items.sku,items.qty
ord_A100,widget,2
ord_A100,gadget,5

Parent fields repeat on each row, but the result is normalized and groups naturally in a pivot table.

Common conversion problems

"My CSV has shifted columns"

The source array contains objects with different keys, and the converter wrote them in insertion order instead of computing a header union. Fix: build the header set from every row, then write values keyed by that set.

"Commas in my values broke the CSV"

The converter didn't quote fields. Any cell containing ,, ", \n, or \r must be wrapped in double quotes, and internal " must be doubled to "". RFC 4180 spells this out.

"Numbers came out as scientific notation in Excel"

That's Excel autoformatting, not a CSV problem. Prefix the value with a single quote ('1234567890123) before opening, or import as text from Excel's Data tab.

"Nested arrays are getting stringified"

The converter fell back to JSON.stringify for anything it couldn't flatten. Pick a strategy from Step 3 explicitly — don't let the converter guess.

"My JSON isn't an array"

Wrap it. { "users": [...] } becomes the array data.users. If the root is a single object, treat it as a one-element array. The interactive JSON tree viewer is the fastest way to find the real array inside a deeply nested response.

Convert in the browser, no upload

The free JSON to CSV converter on JSONZen handles all three steps client-side: it flattens nested objects with dot notation, lets you choose indexed-keys or explode behavior for arrays, and quotes values per RFC 4180. Nothing leaves the browser — useful when the data contains anything you'd rather not paste into a hosted service.

Closing recommendation

Pick the array-of-objects path when your data is already tabular, and the explode path when nested arrays represent line items. For everything else, paste it into the converter and watch how the headers come out — that's usually faster than guessing at the shape.

Related guides

Related tools