JSON Flattener and Unflattener
Turn deep JSON into flat key paths for spreadsheets, search indexes or environment files, and rebuild the nested structure from flat keys or CSV headers.
Runs in your browser. Your files never leave your device. See how to check
…
How to do it
- 1Choose a mode
Tap Flatten, Unflatten, JSON array → CSV or CSV → nested JSON.
- 2Add the data
Paste it, open a .json or .csv file, or keep the sample.
- 3Set the key style
Pick the separator and the array index style, and a maximum depth if needed.
- 4Check warnings
Fix separator collisions or parse errors shown under the input.
- 5Reverse to verify
Press Reverse to run the output back the other way and compare.
- 6Export
Copy the result, download JSON or CSV, or download an Excel file of the flattened rows.
About this tool
Nested JSON is natural for programs and awkward for almost everything else. A spreadsheet needs one value per column, a translation file is often stored as flat keys such as checkout.button.pay, analytics tools and search indexes prefer flat field names, and configuration systems map nested settings to names like DATABASE__HOST. Going the other way is just as common: a colleague edits a sheet whose headers are customer.name and items.0.sku and you need the nested object again. This tool does both directions without a script. Flatten walks the document and writes every leaf value under its full path. Unflatten splits each key on the separator and rebuilds objects and arrays. The JSON array to CSV mode flattens every record and creates the union of all columns, so records with extra fields simply get extra columns, and CSV to nested JSON reads such a sheet back into structured records with numbers and true or false restored.
Key styles
The separator can be any short string: the usual dot, an underscore, a slash for pointer-like paths, a double underscore for environment variables, or a colon. Array positions can be written as plain numbers (items.0.sku), in brackets (items[0].sku), or arrays can be kept whole as JSON text when you only want to flatten objects. A depth limit stops flattening after a chosen number of levels, so deeper parts stay as JSON values inside the cell. Empty objects and arrays are kept as {} and [] by default so that the round trip is exact; untick the option to drop them.
Collisions and round trips
If an original key already contains the separator, for example a key called x.y while you flatten with dots, the flat result cannot be split back the same way. The tool warns you and names the keys, so you can switch to another separator or to bracket style, where such keys are quoted as ["x.y"]. When unflattening, numeric path parts become array indexes by default; untick the option when your keys are numeric IDs that should stay object keys.
Spreadsheet export
JSON array to CSV produces comma, semicolon or tab separated text and an Excel file with a frozen header row. A preview table shows the first fifty rows. Nothing is guessed about meaning: the values are written as they are, and nested arrays become numbered columns such as tags.0 and tags.1.
Limits
This is not a full ETL tool. It does not pivot, filter or merge files, and it does not change value formats such as dates. Very wide data with thousands of distinct paths produces equally wide CSV files that some spreadsheet programs open slowly. The tool reads JSON, not JSON with comments; clean those first.
Worked example
An online shop exports an order: number A-1009, a customer with a name and an address object, two items with sku, qty and price, paid true and an empty notes array. Flatten with dots gives 12 keys, among them customer.address.city = Chattogram, items.1.sku = MUG-01 and notes = []. Switching Array indexes to bracket style gives items[1].sku. Pressing Reverse feeds the flat object back through Unflatten and returns the original order unchanged. In the JSON array to CSV mode, two customer records produce the columns id, name, contact.email, contact.phone, tags.0 and tags.1; the second record has an empty phone cell, and CSV to nested JSON rebuilds both records.
Quick facts
- Category: Developer & Data
- Works in your browser, no sign-up, no upload.
- Your input stays on your device.
- Available in English.
- Content last reviewed:
- Official source: IETF RFC 8259 (JSON) and RFC 4180 (CSV)
Frequently asked questions
Which separator should I use?
Dots are the most common and are what i18n libraries and many databases expect. Use a double underscore for environment variables, and a slash when you want paths that look like JSON Pointers.
Why do I get a warning about the separator?
Some of your keys already contain it, so unflattening could not tell where one level ends. Choose a different separator or bracket style and the warning disappears.
How are arrays handled?
Each element gets its index in the path, such as items.0.sku. Choose Keep arrays as JSON when you prefer one cell with the whole array.
Will numbers stay numbers when I go back from CSV?
Yes, with Convert numbers, true/false and empty cells ticked. Long digit strings such as phone numbers of more than 15 digits stay text so they are not rounded.
Does it change my values?
No. Values are copied exactly; only the shape of the document changes.
Where is the data processed?
In your browser. Nothing is uploaded, and the last input is stored only in this browser's local storage.
