use case
How to flatten nested JSON to CSV
Convert a JSON response with nested objects into a flat CSV table.
Many APIs return nested JSON structures — an order object might contain a customer sub-object and a shipping address sub-object. Spreadsheets and SQL tables are flat. This guide shows how to automatically flatten nested JSON using dot-notation column names so every property ends up in its own column.
Step-by-step guide
- Identify the nesting depth: Look at your JSON structure. If objects contain sub-objects (but not deeply nested arrays), the flatten option handles them automatically. Deeply nested or array-valued fields are stringified into single cells.
- Enable flatten and convert: Paste the JSON array with flatten enabled. The converter uses dot-notation: {address: {city: 'London'}} becomes a column named 'address.city'. Multiple levels of nesting are handled recursively.
- Verify the column names: The 'columns' field in the response lists all generated column names. Check that dot-notation names are meaningful for your downstream tool before importing.
Frequently asked questions
- What happens to array-valued fields during flattening?
- Arrays (e.g. tags: ['a', 'b']) are not recursively expanded — they are JSON-stringified into a single cell ('["a","b"]'). Expanding arrays into multiple rows requires a different transformation that is outside the scope of a flat table.
- Can I import dot-notation column names into a database?
- Most databases require column names without dots. Rename the columns after import, or set flatten to false and handle the nesting in your application code instead.
Try it now
Use the JSON to CSV Converter to complete this task — free, no sign-up, runs in your browser.
Open JSON to CSV Converter →