Flatten JSON Online - Free JSON Flattener Tool
Most APIs return deeply nested JSON that is hard to use in Excel, CSV exports, BI tools, and QA reports. Flatten it into readable path keys instantly, no script required.
Paste your JSON → Get results instantly (no signup)
→ Flatten or nest keys in this JSON structure and flatten nested object.
1{2 "user.name": "Alice",3 "user.address.city": "NYC",4 "user.address.zip": "10001"5}Love the result?
Use this exact pipeline in your app, backend, or LLM workflow.
No setup needed. Works with curl, Node, Python.
Uses example data. For edited input, copy from the playground.
Works with:
- Deeply nested API responses
- Flatten JSON online free workflows
- Analytics event payloads
- JSON destined for spreadsheet tools
Example: input → output
Most APIs return deeply nested JSON that is painful to inspect in Excel, BI tools, test fixtures, and bug reports. Customer names live under user.profile.name, order totals sit beside payment.summary.total, and line items hide several levels down in arrays. A JSON flattener turns those nested values into readable path keys so the data becomes searchable, exportable, and easier to compare.
Use this free online JSON flattener when you need to convert nested JSON to flat JSON without writing a script. It works for objects, arrays of records, API responses, analytics events, and spreadsheet-bound exports. The reverse operation is also available: use Unflatten JSON when flat dotted keys need to become nested objects again.
Flatten JSON example: real-world API response
Input
{
"user": { "name": "Ada", "email": "ada@example.com" },
"active": true
}
Output
{ "user.name": "Ada", "user.email": "ada@example.com", "active": true }
Nested API input:
{
"order": {
"id": "ord_1001",
"customer": {
"email": "ada@example.com",
"plan": "pro"
},
"totals": {
"subtotal": 49,
"tax": 4.41
}
}
}Flattened output:
{
"order.id": "ord_1001",
"order.customer.email": "ada@example.com",
"order.customer.plan": "pro",
"order.totals.subtotal": 49,
"order.totals.tax": 4.41
}That output is much easier to scan in a diff, paste into a support ticket, or send into the JSON to CSV converter. Nested objects become columns instead of opaque blobs.
How to flatten JSON online
- Paste a nested JSON object or array into the input panel.
- Choose the flatten direction and delimiter, usually
.,_, or/. - Run the tool to convert nested paths into flat keys.
- Copy the flattened JSON, or pass it into a converter, cleaner, or diff step.
If your input is an array of records, use the Flatten JSON Array page for array-specific examples. If your final goal is a spreadsheet, use Flatten JSON for CSV before export. If you are looking for the no-signup query directly, use Flatten JSON Online Free.
When to use this tool
Use Flatten JSON when nested paths are the obstacle: spreadsheet columns, path-level diffs, QA reports, API debugging, test fixtures, or ETL preprocessing. If the final destination is CSV, preview the flattened paths here and then use Nested JSON to CSV or JSON to CSV.
Best way to flatten JSON in 2026
The best way to flatten JSON is to start from the destination, not the source. CSV and Excel need stable columns. Debugging needs readable paths. Backend code may need to preserve arrays and types. A quick path map is useful only if the next tool can consume it.
For most workflows:
- Validate or clean the JSON if it came from a copied snippet.
- Choose a delimiter that will survive the destination.
- Flatten objects first, then decide what to do with arrays.
- Keep the original nested JSON as the source of truth.
- Export, diff, extract fields, or unflatten only after the flat shape looks right.
Use Flatten JSON with a Delimiter when dots, slashes, or underscores matter. Use Flatten Large JSON Files when the payload is a big export or event batch.
Flatten JSON array vs object
Flattening a single object creates one flat object. Flattening an array usually creates one flat object per record, which is the shape CSV, Excel, and reporting tools expect.
Object input:
{ "user": { "name": "Ada", "active": true } }Flat object:
{ "user.name": "Ada", "user.active": true }Array input:
[
{ "user": { "name": "Ada" } },
{ "user": { "name": "Grace" } }
]Flat array:
[
{ "user.name": "Ada" },
{ "user.name": "Grace" }
]Arrays inside each record are the tricky part. You can preserve them, expand indexed paths such as items.0.sku, or normalize line items into separate rows with a downstream tool. Choose based on where the data is going.
Common use cases of Flatten JSON
CSV files are flat. A column can be named customer.email, but it cannot contain a true nested object. Flattening first turns every nested JSON path into a column candidate:
customer.emailshipping.address.citypayment.card.branditems.0.sku
That is why a JSON flattener often belongs before CSV export. Use Flatten JSON for CSV when you are preparing data for Excel, Google Sheets, Tableau, Power BI, or a finance handoff.
Flatten JSON in JavaScript
Developers often search for a JavaScript flatten JSON helper because they need a predictable path map in frontend tests, Node scripts, or API debugging. The common pattern is recursive: walk each object, append the current key to the path, and emit primitives at the leaves.
The online tool helps you preview the exact output before committing to a helper function or library. For JavaScript-specific snippets and caveats around arrays, dotted keys, and null, use Flatten JSON in JavaScript.
Flatten JSON for APIs
API payloads usually contain nested identity, billing, permissions, metadata, and event context. Flattening an API response is useful when you need to:
- Compare sandbox and production payloads with the JSON Diff tool.
- Give support or QA a path-level report.
- Find missing fields across vendor responses.
- Prepare webhook samples for docs, tests, or import scripts.
Use Flatten API Response JSON for REST, GraphQL, webhook, and vendor SDK examples.
Flatten JSON vs Normalize vs Extract Fields
These operations are often confused because they all make JSON easier to work with, but they solve different problems. JSONPath belongs in the comparison too, because many developers reach for JSONPath when they really need a transformation.
| Operation | What it changes | Best for |
|---|---|---|
| Flatten JSON | Converts nested paths into flat keys | CSV columns, path-level diffs, spreadsheet review |
| Normalize JSON | Makes record shapes consistent | Inconsistent API arrays, missing fields, repeated schemas |
| Extract fields | Keeps only selected values | Smaller payloads, LLM prompts, focused exports |
| JSONPath | Finds values without reshaping the whole document | Queries, selectors, one-off lookups |
Use flattening when the destination expects columns or path-level keys. Use Normalize JSON when every record needs the same schema before export. Use Extract Fields from JSON when you only need a handful of fields. Use JSONPath-style selection when you want to locate values without transforming the whole payload.
Example: if customer.address.city should become a CSV column, flatten. If some records have city and others have town, normalize. If you only need customer.email and invoice.total, extract fields. If you only want to inspect every city value, query it.
Why flattening breaks CSV sometimes
Flattening is usually the fix for CSV export, but it can still create bad CSV when the output shape is wrong. The most common failure is expanding long arrays into hundreds of indexed columns such as items.0.sku, items.1.sku, and items.99.sku. That works for tiny fixed arrays, but it is a poor fit for line items, logs, and events.
Delimiter choice can also break downstream tools. Some spreadsheets and BI tools treat dots in headers as special paths. Some databases dislike dots in field names. If that happens, choose _ or / instead of ..
The safe CSV workflow is: flatten a sample, inspect the column count, normalize records if needed, then export with JSON to CSV.
Common errors when using Flatten JSON
- Delimiter collisions - if an original key already contains
., a dotted path can become ambiguous. Pick_or/instead. - Array expansion surprises - indexed paths such as
items.0.nameare readable but can create many columns. - Mixed record shapes - some rows may miss fields that other rows contain. Run Normalize JSON first when every record needs the same keys.
- Over-flattening - flattening too deeply can create a very wide object. Limit depth when only top-level grouping matters.
- Losing the source - keep the original nested JSON as the canonical copy when an API or application still expects structure.
Common errors developers hit
nullrecursion bugs - in JavaScript,typeof nullis"object", so recursive flatten helpers must treatnullas a leaf.- Python list handling - flattening dicts is simple; flattening lists requires a deliberate choice between preserved arrays and indexed paths.
- Node.js
undefinedvalues -undefinedis not valid JSON, so normalize it before treating an object as a JSON payload. - Dotted source keys - a source key named
user.nameconflicts with an output path nameduser.nameunless you escape or change the delimiter. - Type loss before export - stringify too early and numbers, booleans, and nulls become harder to handle in CSV, tests, and APIs.
For language-specific examples, use Flatten JSON in JavaScript, Flatten JSON in Python, or Flatten JSON in Node.js.
Why use this Flatten JSON tool
This tool runs in your browser and keeps value types intact: strings stay strings, numbers stay numbers, booleans stay booleans, and arrays stay arrays unless you choose to expand them. It is pipeline-aware, so you can flatten first, then convert to CSV, diff two versions, extract fields, clean the result, or unflatten the data again without copying between unrelated tools.
Example pipelines on GitHub
The ForgeJSON Pipeline Spec repo includes portable flatten JSON examples you can inspect, copy, or version with your own tooling:
- Flatten nested JSON pipeline
- Flatten JSON for CSV pipeline
- Flatten API response pipeline
- Unflatten JSON pipeline
These examples are plain JSON pipeline documents, so they work as documentation, test fixtures, or starting points for automation.
Related tools
- Flatten JSON Array - examples for arrays of records, indexed paths, and nested line items.
- Flatten JSON for CSV - prepare nested JSON for CSV, Excel, Sheets, and BI tools.
- Flatten JSON in JavaScript - preview dotted path maps before writing a JS helper.
- Flatten JSON in Python - compare flat paths with dict helpers and pandas workflows.
- Flatten JSON in Node.js - flatten webhook payloads, fixtures, and server-side imports.
- Flatten JSON Online Free - no-signup browser-based flattening.
- Flatten Large JSON Files - guidance for big exports, logs, and event batches.
- Flatten Large JSON Datasets - sample-first workflow for exports, logs, and analytics data.
- Flatten JSON with a Delimiter - choose dot, slash, or underscore separators.
- Flatten JSON API Example - step-by-step nested API response example.
- Flatten JSON for Testing - fixtures, snapshots, assertions, and mocks.
- Flatten API Response JSON - flatten REST, GraphQL, webhook, and vendor payloads.
- Unflatten JSON - rebuild nested objects from flat path keys.
Frequently asked questions
What does flattening JSON mean?+−
Flattening turns a deeply nested object into a single level where each key encodes its full path. A value at user.address.city becomes the key 'user.address.city' at the top level of the output.
Can I un-flatten the result back into nested JSON?+−
Yes. The same tool runs in reverse — pick the nest direction and supply the same delimiter. The result round-trips back to the original shape as long as no field name contained the delimiter.
What delimiter should I use between path segments?+−
The default is a dot (user.address.city). Underscores and slashes are also common, especially when downstream consumers can't handle dots in column names. Pick whatever survives your destination format.
Does flattening affect arrays?+−
By default arrays stay as arrays. If you want arrays expanded into indexed paths (items.0.name, items.1.name), enable the array-flattening option.
When should I flatten before converting to CSV?+−
Always, when the JSON has nested objects you want to inspect column-by-column. Flattening turns nested fields into readable columns instead of stringified blobs.
Common next steps
Related tools
- Rename KeysRename known keys or convert key casing without changing the underlying values
- Find & ReplaceFind and replace matching keys or values across JSON using broad search patterns
- FilterFilter rows, items, keys, or values by explicit conditions and keep only the matches you want
- Pick FieldsKeep only a known allowlist of fields and remove everything else
- RestructureFlexibly restructure collections by grouping, unwinding, transposing, or rearranging nested data
Read more on the blog
Advanced usage (optional)
Flatten / Nest
v1.0.0Description
Flatten / Nest
Convert between nested and flat object structures. Flatten deep objects into single-level key-value pairs, or nest flat keys back into hierarchical objects. Supports multiple key formats: delimiter-separated, camelCase, snake_case, PascalCase, and kebab-case.
Modes
Flatten
Convert nested objects into flat keys. Each nested path becomes part of the key name.
{ "user": { "name": "Alice" } } → { "user.name": "Alice" }Nest
Convert flat keys back into nested objects by splitting on the delimiter or case boundaries.
{ "user.name": "Alice" } → { "user": { "name": "Alice" } }Key Formats
Delimiter (default)
Join/split key segments with a character (default: .).
- Flatten:
user+name→user.name - Nest:
user.name→user/name
camelCase
Join/split on uppercase letter boundaries.
- Flatten:
user+address+city→userAddressCity - Nest:
userAddressCity→user/address/city
snake_case
Join/split on underscores.
- Flatten:
user+address+city→user_address_city - Nest:
user_address_city→user/address/city
PascalCase
Same as camelCase but with uppercase first letter.
- Flatten:
user+name→UserName
kebab-case
Join/split on hyphens.
- Flatten:
user+name→user-name
Configuration
| Field | Type | Default | Description |
|---|---|---|---|
| Mode | enum | flatten | flatten or nest |
| Key Format | enum | delimiter | delimiter, camelCase, snake_case, PascalCase, or kebab-case |
| Delimiter | string | . | Character(s) used to join/split key segments (only for delimiter format) |
| Max Depth | number | 0 | Maximum nesting depth to flatten (0 = unlimited) |
| Target Paths | path-picker | [] | Scope operation to specific paths only (empty = apply everywhere) |
Use Cases
API Integration
- Flatten for forms: Convert nested API responses to flat form field names
- Nest for APIs: Convert flat form data back to nested API request bodies
- Format conversion: Transform between dot-notation and camelCase conventions
Database Operations
- MongoDB flattening: Flatten nested documents for tabular export
- SQL mapping: Convert hierarchical JSON to flat column names for SQL insertion
- Schema migration: Convert between naming conventions (snake_case ↔ camelCase)
Configuration Management
- Environment variables: Flatten config objects to dot-notation for
.envfiles - Depth limiting: Flatten only the first level while preserving deep structures
Configuration
| Name | Type | Default | Description |
|---|---|---|---|
| Mode | enum | flatten | flatten: convert nested objects to flat keys. nest: convert flat keys back to nested objects. flatten nest |
| Key Format | enum | delimiter | delimiter: use a character to join/split. Others: camelCase, snake_case, PascalCase, kebab-case. delimiter camelCase snake_case PascalCase kebab-case |
| Delimiter | string | . | Character(s) used to join/split key segments (default is dot) |
| Max Depth | number | 0 | Maximum nesting depth to flatten (0 = unlimited) |
| Target Paths | path-picker | [] | Scope operation to specific paths only (empty = apply everywhere) |
Examples
Flatten or nest keys in this JSON structure and flatten nested object.1{2 "user.name": "Alice",3 "user.address.city": "NYC",4 "user.address.zip": "10001"5}API Usage
curl -X POST https://your-domain.com/api/v1/utilities/structure.flatten-nest \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"inputs":{"primary":{"user":{"name":"Alice","address":{"city":"NYC","zip":"10001"}}}},"config":{"mode":"flatten","delimiter":".","maxDepth":0,"targetPaths":[]}}'1{2 "user.name": "Alice",3 "user.address.city": "NYC",4 "user.address.zip": "10001"5}