Quoted keys stay unambiguous
A key such as a.b is written ["a.b"], never as a.b, so it cannot be mistaken for a nested object. Quotes and backslashes inside the key follow JSON string rules.
Paste a nested object or array on the left. Arrays become [0], [1], … path segments.
A small order with a customer object, two line items, and a null note
Flattening and unflattening run in this browser tab only. Your JSON is not sent to our servers, and there is no cloud store for the trees you paste.
Use this page to flatten JSON into path keys, or unflatten a path object back into a tree. Switch the mode above the editors and copy pretty-printed JSON — a lossless walk of the tree, not a spreadsheet.
For flatten mode, paste an object or an array. For unflatten mode, paste the single-level object this tool (or a compatible path syntax) produced. To inspect structure without rewriting it, use the JSON viewer.
{
"order": {
"id": "ORD-1042",
"customer": {
"name": "Lina Ortiz",
"vip": true
},
"items": [
{ "sku": "mug", "qty": 2 },
{ "sku": "coaster", "qty": 4 }
],
"notes": null
}
}Ordinary names are joined with dots (order.customer.name). Array members use brackets (items[0].sku). Keys that contain dots, spaces, or other punctuation are JSON-quoted inside brackets so they cannot be confused with a nested walk.
{
"order.id": "ORD-1042",
"order.customer.name": "Lina Ortiz",
"order.customer.vip": true,
"order.items[0].sku": "mug",
"order.items[0].qty": 2,
"order.items[1].sku": "coaster",
"order.items[1].qty": 4,
"order.notes": null
}Copy or download the pretty-printed result. Switch to Unflatten and paste the path object to rebuild the original tree. If what you actually need is a worksheet of columns, that is a different job — use JSON to Excel or JSON to CSV.
When you flatten JSON, every leaf of the tree becomes one key. The spelling is chosen so unflatten can invert it.
| Path | Meaning |
|---|---|
order.customer.name | Plain identifiers joined with dots |
items[0].sku | The first element of the items array |
[0].id | A root-level array: first element’s id |
["a.b"] | An object key that literally contains a dot |
["first name"] | A key with a space, JSON-quoted inside brackets |
A key such as a.b is written ["a.b"], never as a.b, so it cannot be mistaken for a nested object. Quotes and backslashes inside the key follow JSON string rules.
An empty object or empty array that is not at the root is stored as the value of its path (meta: {}, tags: []) so the round-trip can put it back.
unflatten(flatten(x)) equals x for the cases this page promises — and one root case it does not.
Plain objects, arrays (including a root array), nested mixes, null leaves, empty nested objects and arrays, and keys that contain dots or spaces all survive a flatten-then-unflatten cycle.
Both [] and {} flatten to an empty object. Unflatten therefore rebuilds {}. Nested empty arrays are not affected by this gap.
A primitive or null at the root cannot be flattened. Circular references throw. Unflatten expects a single-level object of path keys — not an array — and reports colliding paths if one key wants an array where another wants an object.
A path object is still JSON. Sending nested data to columns is a separate workflow.
Flattening to a spreadsheet is a different job. Use JSON to Excel or JSON to CSV when you want rows and columns rather than path keys.
The JSON path finder highlights JSONPath expressions for one value without rewriting the whole document.
Open a large tree in the JSON viewer, or diff two documents with Compare JSON.
Questions about path syntax, quoted keys, round-trip unflatten, and how this differs from a spreadsheet export
Edit, format, and beautify JSON
Validate, fix, and inspect JSON
Compare, measure, and map JSON
Convert JSON to other formats
Convert other formats to JSON
Convert, format, fix, and minify XML
Generate code and format other languages