How to Unflatten JSON: Rebuild Nested Objects from Dot Notation
Flat key-value data from a spreadsheet or key-value store is hard to use as-is. This guide explains how JSON unflattening rebuilds the original nested objects and arrays, safely, in your browser.
Somewhere along the way, your nested JSON got squashed into a flat list of dotted keys - maybe it came out of a spreadsheet export, an environment-variable dump, or a key-value store that only understands strings. Whatever the source, you now have user.address.city sitting next to user.roles.0 instead of the tree structure your application actually expects.
Unflattening reverses that process. It reads every dotted key path and rebuilds the objects and arrays they describe, restoring the exact shape the data started in. The JSON Unflattener does this instantly in your browser, so you can go from a flat key map back to usable, nested JSON without writing a parsing script yourself.
What is JSON unflattening?
Unflattening takes an object whose keys are dot-notation paths - user.name, user.roles.0, settings.theme.color - and reconstructs the deeply nested structure those paths describe. Every dot marks a step down into a nested object; a numeric segment marks a step into an array index instead. The result is functionally identical to the original document before it was ever flattened.
It is the exact inverse of flattening, which collapses a nested document into single-level dotted keys for easier storage or comparison. If you flattened data with the JSON Flattener earlier in your workflow, unflattening is how you get the original shape back.
Flat keys to nested JSON
A dotted key map rebuilt into an object with a nested array.
Input
{
"user.name": "Mira",
"user.roles.0": "admin",
"user.roles.1": "editor",
"user.address.city": "Austin"
}Output
{
"user": {
"name": "Mira",
"roles": ["admin", "editor"],
"address": {
"city": "Austin"
}
}
}Why unflattening matters
Flat data is convenient for storage and diffing, but it is awkward for almost everything else. Application code expects to walk user.address.city as a real object path, not to parse it out of a string key at runtime. Rebuilding the nesting up front removes that friction:
- Drop-in compatibility - a rebuilt document can be passed straight to code, an API, or a config loader that expects real nesting.
- Correct arrays, not object-like maps - numeric segments become actual array elements, not objects keyed
"0","1","2". - Fewer manual scripts - you avoid writing a one-off loop every time a spreadsheet or key-value export needs to become JSON again.
- A clean round trip - combined with JSON Flatten, you can flatten for editing or comparison and unflatten back to the exact original structure.
How JSON unflattening works
The tool walks every key in the flat object and splits it on the delimiter - a dot by default, but you can choose a slash, underscore, or any custom separator to match how the data was originally flattened. Each segment becomes one level of nesting: a plain string segment creates or reuses an object key, while a segment made entirely of digits creates or reuses an array index at that level.
As paths are processed, the tool merges them into a single growing tree. user.roles.0 and user.roles.1 are recognized as two elements of the same roles array under user, not two separate values. If the delimiter you choose does not match the one used to flatten the data, paths will split in the wrong places and the rebuilt structure will not match the original - so getting that setting right matters more than anything else in the process.
Watch for conflicting paths
It is possible for a flat key set to be internally inconsistent - for example, one key implies settings is a plain string while another implies settings.theme is nested underneath it. The JSON Unflattener detects that kind of conflict and reports it clearly instead of silently overwriting one value with the other.
Step-by-step: unflatten JSON in your browser
- Open the JSON Unflattener and paste in your flat, dot-notation object.
- Set the delimiter to match exactly what was used when the data was flattened - dot, slash, underscore, or a custom character.
- Run the conversion. The tool expands every key path into nested objects and arrays in one pass.
- Review the result - numeric segments should appear as arrays, and any conflicting paths will be flagged rather than silently merged.
- Copy the rebuilt JSON or download it for use in your app, config, or API request.
There is nothing to install and no account required - paste, pick the delimiter, and the nested structure appears immediately.
Common use cases
- Restoring structured JSON from a spreadsheet that was exported with dotted column headers.
- Turning flat, environment-style configuration keys back into a nested config object.
- Rebuilding nested API payloads from data pulled out of a flat key-value store.
- Reassembling localization or translation files that were stored as dotted string paths.
- Finishing a flatten-edit-unflatten workflow after editing individual values in a spreadsheet or CSV.
Common mistakes and how to avoid them
Using the wrong delimiter
If your keys were flattened with underscores (user_address_city) but you unflatten with a dot, every key will be treated as a single unbroken segment instead of three nested levels. Always check what separator produced the flat keys before you rebuild them.
Non-sequential array indices
Arrays are rebuilt from numeric segments like roles.0 and roles.1. If indices are missing or out of order - say roles.0 and roles.2 with no roles.1 - the resulting array will have a gap. Make sure exported data preserves contiguous indices if you need a clean array back.
Conflicting types at the same path
A flat export can accidentally contain both settings as a direct value and settings.theme as a nested key. That is a real contradiction - one key says it is a leaf, the other says it is a container - and a reliable tool should surface the conflict rather than guess which one wins.
Numeric-looking keys that should stay objects
Occasionally an object key is meant to be a literal numeric string, such as a product ID used as a map key, not an array index. Since the tool treats any all-digit segment as an array index, double-check the rebuilt output when your data mixes numeric object keys with genuine arrays.
Best practices for unflattening JSON
- Confirm the delimiter used during flattening before you unflatten - mismatched separators are the most common source of broken output.
- Unflatten first, then run the result through the JSON Formatter to review the rebuilt structure clearly indented.
- If you need to compare the rebuilt document against the original, use JSON Compare to confirm nothing was lost or misplaced.
- For data coming from spreadsheets, export as CSV and consider CSV to JSON directly when the source truly is tabular rather than dot-notation flattened.
- Treat any reported path conflict as a data-quality bug to fix at the source, not something to paper over by picking one value arbitrarily.
Your data never leaves your browser
Unflattening is pure computation - reading keys and rebuilding a tree - so it can run entirely on your device. The JSON Unflattener never uploads, logs, or stores what you paste in, which means it is safe to rebuild flat exports containing customer records, credentials, or other sensitive values.
Related tools
Flatten nested JSON into single-level dot-notation key paths.
Parse CSV into a clean array of typed JSON objects, header-aware.
Pretty-print JSON with configurable indentation and instant validation.
Explore JSON as a collapsible, interactive tree.
Related guides
Nested JSON is hard to drop into a spreadsheet, an .env file, or a flat key-value store. This guide explains how flattening converts nested structures into dot-notation keys, when to use it, and the mistakes to avoid.
Turning a spreadsheet export into usable JSON is trickier than a simple comma split. This guide covers headers, quoting, delimiters and type inference, plus how to convert CSV safely in your browser.
Minified JSON is unreadable and hard to debug. This guide covers how JSON formatting works, when to use it, common mistakes, and how to pretty-print JSON without uploading it anywhere.
Raw JSON text hides its own shape. This guide shows how a collapsible tree view turns an unfamiliar payload into something you can scan, search, and navigate in seconds.