/

JSON Flattener

Processed Client Side

Convert nested JSON into flat key-value pairs — every leaf on one line, addressed by its full path.

Nested JSON
JSONLength: 452Lines: 21Size: 452 BytesCursor: 1:1
Flattened · JSON
20 keys
JSONLength: 520Lines: 22Size: 520 BytesCursor: 1:1
20 keys · 3 levels deep · 2 arrays

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

  1. Paste your nested JSON into the left pane, replacing the sample order.
  2. Choose the separator for object keys, and whether array indexes are written as items[0] or items.0.
  3. Pick the output shape — JSON object, key = value lines, or CSV — and the indentation if you chose JSON.
  4. Set a depth limit if you only want the top levels flattened and the rest left whole.
  5. 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.
  6. 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.

Related tools

Browse all 24 JSON tools

Frequently asked questions

11

Paste the nested JSON into the left pane and the flattened version appears on the right immediately, updating as you type. Every leaf value gets one line, named by the full path down to it — customer.address.city, items[0].sku. Then copy the result or download it as .json, .txt or .csv. Nothing is uploaded; the flattening runs in your browser.

It turns a tree into a single-level list. { "customer": { "address": { "city": "London" } } } becomes one entry, customer.address.city = London. No value changes and nothing is summarised — the nesting simply moves out of the structure and into the key, which is what makes the result easy to put in a spreadsheet column, a properties file or a line-by-line diff.

Yes — dot, underscore, slash, dash or double colon. Pick one your own keys do not contain. If a key already has the separator in it, the tool says so, because that is the case where the path stops being reversible: a.b.c could mean two different documents once the key a.b is written with a dot.

Either, from a toggle. items[0].sku is what Spring and most Java property loaders expect; items.0.sku is what a lot of JavaScript config libraries and MongoDB queries expect. Both describe the same data, and the JSON Unflattener reads both, so the choice is only about what will consume the file.

By default they are kept as leaves, so an empty object appears as {} and an empty array as []. That is deliberate: an empty object is information — it distinguishes a field that came back empty from one that was never sent. Switch "Keep empty {} []" off if the consumer of the file cannot handle them.

Yes. Set a depth limit of 1 to 5 and flattening stops there, keeping everything below as a whole value. On a large API response that gives you the envelope — meta, links, the record count — with each record still intact, which reads far better than several thousand fully expanded paths.

The output can be a JSON object of paths, key = value lines, or a two-column CSV with a key,value header. The lines format is close to a .properties or .env file and is fine for reading and diffing, but note that most dotenv parsers reject dots and brackets in a key, so it is not a drop-in environment file.

No. In the text formats a string that spells a number, a boolean or null keeps its quotes — "42" is written as "42" while the number 42 is written bare. That is what lets an order id like 0042 or a version like 1.10 survive a trip out to CSV and back through the JSON Unflattener unchanged.

Because a path cannot tell a numeric key from an array index. A status map like {"404": "Not found", "500": "Server error"} flattens to the paths 404 and 500, and expanding those reads the digits as positions — so you get an array of 501 entries with your two values stranded at the end, rather than the object you started with. Unflatten with "Numbers make arrays" switched off and it comes back correctly. The problem only arises when every key is digits: {"404": "…", "message": "…"} is safe and is not warned about, because the named key keeps it an object.

Yes — paste the output into the JSON Unflattener with the same separator and you get the document you started with. The two tools share one path grammar for exactly this reason. Three things break the round-trip — a key that already contained the separator, a key containing bracket syntax such as a[0], and an object whose keys are all digits — and the flattener warns about each of them. It checks by re-reading every path the way the unflattener will, so an empty warning list means the document really does come back unchanged.

No. The parsing, flattening and formatting are all JavaScript running in your browser tab, and there is no request that sends the text anywhere. That is what makes it safe to paste an API response full of customer records, or a production config, without clearing it first.