JSON Flattener
Processed Client SideConvert nested JSON into flat key-value pairs — every leaf on one line, addressed by its full path.
Bookmark this tool now — skip the search next time you need it.
About JSON Flattener
This tool runs entirely in your browser. Whatever you paste is processed on your own device and is never uploaded, logged, or sent to any server.
The JSON Flattener collapses a nested document into a flat list of paths: every leaf value gets its own line, addressed by the full route down to it — customer.address.city, items[0].sku, totals.gross. That single-level shape is what a spreadsheet column, a .properties file, a translation catalogue, a feature-flag store and a line-by-line diff of two configs all want, and it is the shape a nested document is hardest to produce by hand. Both halves of the path grammar are yours to choose: the separator between object keys, and whether an array index is written as items[0] or items.0. The result comes out as a JSON object of paths, as key = value lines, or as a two-column CSV you can open in a spreadsheet. Nothing is uploaded — the flattening runs in your browser tab, on text that never leaves it.
Key features
- Every leaf addressed by its full path — objects joined by your chosen separator, arrays written as items[0] or items.0
- Five separators to pick from: dot, underscore, slash, dash and double colon, for when the data itself contains dots
- Three output shapes from one toggle: a JSON object of paths, key = value lines, or a two-column CSV with a header row
- A depth limit that stops at 1–5 levels and keeps whatever is below as a whole value, which is how you flatten only the envelope of a large API response
- Empty objects and arrays kept as {} and [] leaves rather than silently vanishing — or dropped, if you would rather they did
- Type-preserving text output: strings are written bare, but a string that spells 42, true or null keeps its quotes so it reads back as text
- Warnings where flattening is genuinely lossy — a key that already contains your separator or bracket syntax, a key that is all digits, or two locations that collapse onto the same path. Every path is re-read as the unflattener would read it, so the warning appears exactly when the round-trip would not be clean
- Counts for the flattened document: how many leaves came out, how deep the deepest one was, and how many arrays were walked
- Exact round-trip with the JSON Unflattener — the two tools share one path grammar, so anything flattened here expands back to the original document
- Syntax highlighting in both panes, copy to clipboard, and download as .json, .txt or .csv
- Runs entirely in your browser — an API response full of customer data is never sent anywhere
How to use it
- Paste your nested JSON into the left pane, replacing the sample order.
- Choose the separator for object keys, and whether array indexes are written as items[0] or items.0.
- Pick the output shape — JSON object, key = value lines, or CSV — and the indentation if you chose JSON.
- Set a depth limit if you only want the top levels flattened and the rest left whole.
- Read the badges under the output for the key count and depth, and the warning list below the toolbar if anything about the input is ambiguous.
- Copy the result, or download it as a .json, .txt or .csv file.
Tips & common mistakes
- Match the path style to whatever will read the file. Spring and most Java property loaders expect items[0].sku; a lot of JavaScript config libraries and MongoDB queries expect items.0.sku. The two are the same data written two ways, and the wrong one is silently ignored rather than rejected.
- If your object keys contain dots — domain names, version numbers, file names — switch the separator to :: or /. The tool warns when a key already contains the separator, and again when one contains bracket syntax such as a[0], because brackets mark an array index in a path whichever array style you picked. Those are the cases where the path becomes ambiguous and will not unflatten back to what you started with.
- An object whose keys are all digits is the subtle one, and it is warned about too. A status-code map like {"404": "…", "500": "…"} flattens to the paths 404 and 500, and nothing in a path distinguishes a numeric key from an array index — so unflattening rebuilds it as an array with your two values stranded at positions 404 and 500. The fix is on the other side: turn off "Numbers make arrays" in the JSON Unflattener. A mixed object such as {"404": "…", "message": "…"} is safe and is not warned about, because the named key forces it back to an object.
- The key = value output looks like a .env file but is not one. Most dotenv parsers reject dots and brackets in a key, and none of them will rebuild the nesting. Use it for reading and diffing, not as a drop-in environment file.
- Flatten two versions of the same config, then paste both into a diff: one changed value shows up as one changed line instead of a re-indented block. It is the quickest way to see what actually differs between a staging and a production config.
- The depth limit is for inspecting large payloads. Stopping at 2 levels gives you the envelope — meta, links, the count of records — with each record still whole, which is far more readable than five thousand fully expanded paths.
- Turn off "Keep empty {} []" only if the consumer cannot handle them. An empty object is information: it is the difference between a field that came back empty and a field that was never sent, and dropping it makes the two indistinguishable.
- A string that reads as a number keeps its quotes in the text formats — "42" comes out as "42" while the number 42 comes out bare. That is what lets the CSV and lines output round-trip through the unflattener without a postcode or an order id turning into a number.
- The CSV output is one row per leaf with a key and value column, which spreadsheets sort and filter well. It is a good format for handing a config to somebody who does not read JSON, and for the translation and content-key lists that end up in a spreadsheet anyway.
- Flattening is a view, not a conversion — nothing is lost as long as the warnings are empty. When they are, the JSON Unflattener with the same separator gives you back the exact document you pasted.