JSON Flattener

Turn nested JSON into flat, dot-notation key/value pairs for CSV columns, spreadsheets or diffs.

Document Tools● Free No upload Instant

Loading JSON Flattener…

Your browser is preparing the tool. It runs 100% locally.

Quick answer

The JSON Flattener collapses nested JSON into a single-level object where every key is a dot path, like user.address.city. Array items get a numeric index, so tags becomes tags.0, tags.1. Only the leaf values are kept; the structure becomes the key. It needs valid JSON and outputs valid, pretty-printed JSON, all in your browser.

What the JSON Flattener does

It walks a nested JSON object and rewrites it as flat key/value pairs, where each key is the full path to a value. That is the shape you need when a target system expects columns, such as a CSV export, a spreadsheet, a BI tool or a SQL table.

It also gives you stable, predictable keys, which makes flattened JSON handy for searching logs by path or diffing two payloads to see what changed.

How it works

It parses your JSON, then recursively walks the tree. Each time it reaches a leaf value (a string, number, boolean or null) it records the full dotted path as the key.

Objects add their key to the path; arrays add the element's index. The result is serialised back to neatly indented JSON.

Data source & conversion logic

  1. Parse the JSON. It reads your input as JSON. Invalid JSON (comments, trailing commas, single quotes) is rejected with an error.
  2. Walk the tree. It recurses through every object and array, building up a path string as it descends.
  3. Emit a key per leaf. At each leaf value it records the full dotted path as the key. Objects contribute their key and arrays contribute the index.
  4. Output flat JSON. It serialises the flat object to pretty-printed JSON you can copy or download.

How the keys are built

Nested object → parent.child (dot notation) Array element → arrayname.index (for example tags.0) Only leaf values are kept; the structure becomes the key
Worked example
{"user":{"name":"Alice"},"tags":["x","y"]} → {"user.name":"Alice","tags.0":"x","tags.1":"y"}

Array indices use a dot (tags.0), not bracket notation (tags[0]). Keep that in mind if a downstream tool expects brackets.

Privacy

Your browser parses and flattens the JSON. The site doesn't upload, store or log anything you paste.

There is no account or history; closing the tab clears your data, so it is safe for configs and API payloads.

Technical details

DelimiterDot (.)
ArraysNumeric index (tags.0)
KeepsLeaf values only
InputValid JSON
Reverse (unflatten)?No
Processing100% in-browser

Standards & references

  • JSON (RFC 8259 / ECMA-404): the tool parses standard, strict JSON with double-quoted keys and strings, and no comments or trailing commas.
  • Dot-notation flattening: a single-level object whose keys are the full path to each value; the common shape for mapping JSON onto columns or stable lookup keys.

Accuracy and limits

It requires valid JSON. Comments, trailing commas, single quotes or unquoted keys cause a parse error rather than a guess.

Empty objects and empty arrays produce no key at all. They have no leaf values, so they disappear from the output.

Array indices are written with a dot (tags.0), not brackets (tags[0]). If a downstream tool expects bracket notation you will need to adjust.

If an original key already contains a dot, the flattened path becomes ambiguous, because a dot is also the separator.

It is one-way. There is no unflatten here to rebuild the nested structure from dotted keys.

Where people use it

Preparing JSON for a spreadsheet

Flatten an object so each dotted path becomes a column header for a CSV or Excel import.

Flattening an API response

Turn a deeply nested response into flat key/value pairs that map cleanly onto a table or database row.

Diffing two payloads

Flatten both versions and compare the flat keys to see exactly which fields changed.

Searching logs by path

Use stable dotted keys to grep or look up a specific nested value.

When it fits, and when it doesn't

Good for

  • Mapping nested JSON onto columns
  • Stable keys for lookups and diffs
  • Flattening an API response for a table
  • A quick view of every leaf value and its path

Not the best choice for

  • Keeping the nested structure
  • Rebuilding nesting (no unflatten)
  • JSON whose keys contain dots
  • Invalid or non-standard JSON

To go straight from JSON to a CSV file, use JSON to CSV; to check or tidy the JSON first, use the JSON Formatter or JSON Validator.

Frequently asked questions

What does the JSON flattener do?
It collapses nested JSON into a single level where each key is the full dotted path to a value, such as user.address.city, keeping only the leaf values.
How are arrays handled?
Array elements get a numeric index in the path, so tags becomes tags.0, tags.1, and so on.
Does it use brackets like tags[0]?
No. It uses dot notation for indices (tags.0). If a downstream tool needs tags[0], you will have to convert the notation.
What happens to empty objects or arrays?
They have no leaf values, so they produce no key and drop out of the flattened result.
Does my JSON have to be valid?
Yes. It parses strict JSON. Comments, trailing commas or single quotes cause a parse error.
Can it unflatten, rebuilding the nesting?
No. This tool only flattens. There is no reverse operation here to turn dotted keys back into nested objects.
What if a key already contains a dot?
The path becomes ambiguous, because the dot is also the separator. Avoid dots in keys if you plan to flatten.
Why would I flatten JSON?
Flat key/value pairs map neatly onto columns for CSV, spreadsheet, BI or SQL use, and give stable keys for searching logs or diffing payloads.
Are numbers and booleans preserved?
Yes. Leaf values keep their JSON type, so numbers, booleans and null are written as-is.
Is the output valid JSON?
Yes. It outputs a valid, pretty-printed JSON object with the flattened keys.
Is my data uploaded?
No. Everything runs in your browser and is cleared when you close the tab.
Is it free?
Yes. The JSON Flattener has no sign-up and no usage cap.

References

Checked against this tool's code: it recursively walks objects and arrays, builds a dot-notation path to each leaf value and outputs pretty-printed JSON. It does not unflatten, and it uses dot indices rather than brackets.

Popular

CSV to JSON Converter

CSV rows become a JSON array, keyed by the header row.

DocumentOpen
Popular

JSON to CSV Converter

Flatten a JSON array of objects into CSV columns.

DocumentOpen
Trending

Markdown to HTML

Turn everyday Markdown into clean HTML in your browser.

DocumentOpen

CSV to Excel Converter

Pasted CSV becomes a real .xlsx, with leading zeros kept.

DocumentOpen

Excel to CSV Converter

Pull the first sheet of a workbook out as plain CSV.

DocumentOpen

Excel to JSON Converter

Each spreadsheet row becomes a JSON object keyed by the header.

DocumentOpen

Back to the JSON Flattener

The file never leaves your computer, and you don't need an account.