Flatten Nested JSON Online (Free & Fast)
Flatten deeply nested JSON into a single level — predictable key paths, no scripts.
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
- Analytics event payloads
- JSON destined for spreadsheet tools
Example: input → output
{ "user": { "name": "Alice", "address": { "city": "NYC", "zip": "10001" } }}{ "user.name": "Alice", "user.address.city": "NYC", "user.address.zip": "10001"}About this tool
Flattening nested JSON converts deep object hierarchies into a single level where each key encodes its full path. A field at user.address.city becomes user.address.city at the top level of the output. The reverse operation — nesting — takes flat keys with a delimiter and rebuilds the original shape. Both directions are useful, and which one you need depends on what consumes the data next.
The most common reason to flatten is preparing JSON for a tool that doesn't speak nested objects: CSV exports, BI dashboards, spreadsheet imports, or older databases. A row with user.name and user.email columns reads cleanly; the same row with a stringified { name: ..., email: ... } blob does not. Flattening solves this once at the boundary instead of every time downstream.
Analytics event payloads are another classic input. They tend to be deeply nested with a mix of identifiers, timestamps, and nested context — and they tend to be processed in pipelines that prefer flat keys. Flatten once, hand the result to whichever tool consumes it, and skip the per-event reshape step entirely.
This tool gives you control over the delimiter (., _, /), the casing of generated keys, and the maximum depth. Output is plain JSON with the same value types as the input — strings stay strings, numbers stay numbers, arrays stay arrays. There is no schema generation step; if your input round-trips back through the nesting direction, you'll recover the original shape exactly.
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}