Flatten Nested JSON
Turn nested JSON into rows. Arrays expand into one record per element; nested objects become dot-notation columns. Paste any API response — employees, orders, events — and get a flat structure ready for CSV, SQL, Excel, or Pandas.
How flattening works
Arrays → rows, not indexed keys
{ employees: [{ id: 1 }, { id: 2 }] } becomes two rows — [{ "id": 1 }, { "id": 2 }]. Each array element is a row. No employees[0].id key names that break spreadsheets.
Nested objects → dot-notation columns
{ location: { city: "NYC", country: "USA" } } becomes { "location.city": "NYC", "location.country": "USA" }. Every value becomes a scalar ready for a CSV column or SQL field.
Smart wrapper detection
Paste { employees: [...] } and the tool finds the primary array and expands it — field names come from the elements, not the wrapper key. Output maps directly to table rows.
Configurable separator and depth
Switch to underscore (location_city) for database column names, slash for path-style keys. Set max depth to stop flattening at a specific level and leave deeper objects as JSON strings.
When to use this
API responses → spreadsheet or SQL
Stripe, HubSpot, Salesforce, and most REST APIs return nested JSON. Flatten it and every employee, order, or event becomes a row you can load into Excel, a database, or Pandas.
Preparing data for CSV / SQL export
This tool produces the same row structure the JSON → CSV and JSON → SQL converters need. Use it to preview what the schema will look like before exporting.
Normalizing logs and telemetry
Systems like Elasticsearch and Datadog work best with flat JSON. Deeply nested events can cause field type conflicts across index shards. Flatten first.
Debug inspection (index mode)
Need to see every key-path with its array index? Switch to Index notation to get employees[0].id, employees[1].id — useful for diffing API responses or tracing config changes.
Example
Employee API response — array expanded into rows, nested location flattened to dot-notation columns
{
"employees": [
{
"id": 1001,
"name": "Emma Carter",
"department": "Sales",
"location": {
"city": "Chicago",
"country": "USA"
}
},
{
"id": 1002,
"name": "Liam Nguyen",
"department": "Marketing",
"location": {
"city": "Toronto",
"country": "Canada"
}
}
]
}[
{
"id": 1001,
"name": "Emma Carter",
"department": "Sales",
"location.city": "Chicago",
"location.country": "USA"
},
{
"id": 1002,
"name": "Liam Nguyen",
"department": "Marketing",
"location.city": "Toronto",
"location.country": "Canada"
}
]2 employees → 2 rows. Nested location becomes dot-notation columns. Every value is a scalar — paste directly into CSV, SQL INSERT, or a spreadsheet.
Frequently asked questions
What happens to arrays of objects?
Each array element becomes its own row. { employees: [{id:1, name:"Alice"}, {id:2, name:"Bob"}] } produces two rows — [{id:1, name:"Alice"}, {id:2, name:"Bob"}]. This is the correct structure for spreadsheets, SQL, and analytics tools.
What happens to primitive arrays like tags?
Primitive arrays (strings, numbers) are joined inline: { tags: ["a", "b", "c"] } → { tags: "a; b; c" }. A single column, no extra rows.
How deep does flattening go by default?
All the way — unlimited depth. If your JSON is nested 10 levels deep, all 10 levels are collapsed into the key path. Use the max depth option to stop at a specific level and preserve deeper objects as JSON strings.
What is index notation and when should I use it?
Index notation is a legacy mode that encodes array positions into key names: employees[0].id, employees[1].id. This produces a single wide object, not separate rows — not useful for spreadsheets or SQL. Use it only for debugging, config inspection, or diffing API responses.
What is the difference between dot notation and underscore notation?
Only the separator character. location.city with dot notation becomes location_city with underscores. Use underscores when the output will be a database column name or variable identifier where dots aren't valid.
How is this different from JSON → CSV?
This tool outputs a flat JSON array — you keep the JSON format but with all nesting removed. JSON → CSV takes that flat structure one step further and serializes it as comma-separated rows. Use this when you need flat JSON for an API or a pipeline that expects JSON.
Related Tools
All conversions run in your browser — nothing is uploaded.
Browse all 27 converters →