JSON Flattener
Collapse a nested document into a single level of path keys — and put it back together again when you need the structure returned.
Input
JSON- characters
- 0
- lines
- 0
- size
- 0 B
Options
About this tool
A flat map of path to value is the shape a surprising number of systems want. Feature-flag stores, translation catalogues, environment configuration and most key-value databases all take one level of keys, and the usual way to get there from a nested document is dotted paths.
The important difference from the flattening done inside the CSV converters is that this one preserves types. A number stays a number and a boolean stays a boolean, because the output here is meant to be consumed by JSON-aware code rather than dropped into a spreadsheet cell.
The operation reverses. Unflattening reads the same path keys and rebuilds the nested document, which makes the pair useful for round-tripping config through a system that can only store flat keys.
How to use this tool
Paste JSON, or upload a file.
Choose Flatten or Unflatten.
Pick the path style — dotted, bracketed or underscore-separated.
Press Flatten, then copy or download the result.
Key features
- Types preserved — numbers, booleans and nulls stay themselves
- Three path styles: dotted, bracketed for array indices, or underscore
- Unflatten rebuilds the nested structure from path keys
- Optional depth limit, leaving anything below it as an intact subtree
- Empty objects and arrays kept, because an empty container is not the same as an absent key
- Array indices become path segments, so nothing is lost from a list
Example
Input — JSON
{
"orderId": "SO-2026-0417",
"customer": { "id": 7714, "email": "[email protected]" },
"lines": [{ "sku": "TENT-2P", "quantity": 3 }]
}Output — JSON
{
"orderId": "SO-2026-0417",
"customer.id": 7714,
"customer.email": "[email protected]",
"lines.0.sku": "TENT-2P",
"lines.0.quantity": 3
}Good to know
- Unflattening treats a path segment made only of digits as an array index. An object whose keys were literally "0" and "1" therefore comes back as an array — a property of the notation rather than something the tool can detect.
- A key that already contains the separator character will produce a path that cannot be unflattened unambiguously. Bracket style avoids this for array indices but not for object keys containing dots.
- Underscore style is the most collision-prone of the three, because underscores are common inside real keys. It exists because some environment-variable conventions require it.
Frequently asked questions
How is this different from the flattening in JSON to CSV?
That one produces spreadsheet cells, so every value becomes a string. This one keeps JSON types, because the result is meant to be read back by code rather than opened in Excel.
Is flattening reversible?
Usually, and the Unflatten direction does it. The exception is a document whose own keys contain the separator, or whose object keys are all digits — in both cases the path is genuinely ambiguous.
What happens to arrays?
Their indices become path segments, so lines.0.sku in dotted style or lines[0].sku in bracket style. Nothing is dropped, and the order is recoverable when unflattening.
Why keep empty objects in the output?
Because an empty object is information. A key present with an empty value means something different from a key that is not there at all, and dropping it would change the document.
Further reading
How to flatten JSON — Flattening turns a nested document into a single level of path keys. It is the right answer for key-value stores and spreadsheets, and the wrong one surprisingly often.
Your data stays on your device
Your data is processed locally in your browser and is not uploaded to our server. This page keeps working after you go offline, because there is nothing to send.
Related tools
- JSON to CSVConvertersFlatten an array of JSON objects into a spreadsheet-ready CSV file.JSONCSV
- JSON Path FinderJSON ToolsSearch a JSON document for keys or values and get the JSONPath of every match.JSONJSONPath
- JSON FormatterJSON ToolsPretty-print messy JSON with your choice of indentation and optional key sorting.JSONJSON
- JSON ViewerJSON ToolsBrowse JSON as a collapsible tree, search keys and values, and copy JSONPath.JSONTree
- JSON TransformerJSON ToolsReshape JSON with a safe pipeline of declarative operations — no code.JSONJSON