Unflatten JSON Online
Rebuild nested JSON from flat dotted keys when a spreadsheet export, log line, or path map needs to become an API-ready object again.
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:
- Flat dotted keys
- Spreadsheet exports
- Log-derived path maps
- API request payloads
Example: input → output
Unflatten JSON online
Unflattening JSON is the reverse of flattening. It takes flat path keys such as user.address.city and rebuilds nested objects that APIs, applications, and config files can consume. This is useful after a spreadsheet export, CSV import, log transform, or path-based cleanup step leaves you with flat keys.
This page uses the same reversible engine as the Flatten JSON tool, but the intent is different: convert flat JSON back to nested JSON.
Flat keys to nested JSON example
Input:
{
"user.id": 7,
"user.profile.email": "ada@example.com",
"user.profile.active": true
}Nested output:
{
"user": {
"id": 7,
"profile": {
"email": "ada@example.com",
"active": true
}
}
}The delimiter matters. If the flat keys use dots, choose .. If they use underscores or slashes, match that delimiter so paths split in the right places.
When to unflatten JSON
- Rebuild an API request body from spreadsheet-style keys.
- Convert CSV-derived flat records back into nested objects.
- Restore nested config after a path-level edit.
- Turn log output such as
request.user.idinto structured JSON. - Reverse a flattening step after JSON Diff, cleanup, or export review.
Unflatten JSON arrays
Flat indexed paths can rebuild arrays when the indexes are preserved:
{
"items.0.sku": "book",
"items.0.qty": 2,
"items.1.sku": "pen",
"items.1.qty": 4
}That can become an items array with two objects. This only works reliably when indexes are numeric and complete enough for your destination. If the original array was flattened for CSV, confirm whether the spreadsheet preserved every indexed column.
Common unflattening mistakes
- Choosing the wrong delimiter.
- Trying to unflatten keys that already contain the delimiter as literal text.
- Mixing array indexes and object keys in the same path.
- Expecting missing indexed values to reconstruct perfectly.
- Sending flat JSON back to an API that expects nested objects.
Flatten vs unflatten
Flatten when the next tool wants columns, dotted paths, or simple key-value inspection. Unflatten when the next system expects structured JSON again. Many workflows use both: flatten an API response for CSV review, edit the values, then unflatten the result before sending it back to an endpoint.
For CSV-specific prep, use Flatten JSON for CSV. For JavaScript path maps, use Flatten JSON in JavaScript. For arrays, use Flatten JSON Array.
Related flatten JSON tools
- JSON flattener - flatten nested JSON before reversing it later.
- Flatten JSON Array - create or rebuild indexed array paths.
- Flatten JSON for CSV - understand flat keys created for spreadsheets.
- Flatten API Response JSON - flatten payloads before rebuilding request bodies.
Frequently asked questions
What does unflatten JSON mean?+−
Unflattening converts flat path keys such as user.address.city back into nested objects like { user: { address: { city: ... } } }.
Can unflattening rebuild arrays?+−
Yes, when the flat keys contain numeric indexes such as items.0.sku and items.1.sku. The delimiter and indexes must be preserved.
What delimiter should I choose?+−
Choose the delimiter used in the flat keys. Dotted keys need a dot delimiter, slash-separated keys need slash, and underscore-separated keys need underscore.
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}