JSON Flattener

Turn nested JSON into flat, dot-notation key/value pairs — ready 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 exactly the shape you need when a target system expects columns — 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, 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 JSON is parsed and flattened entirely in your browser. Nothing you paste is uploaded, stored or logged.

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 — double-quoted keys and strings, 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 & Limitations

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 simply 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.

Real-World Use Cases

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 to use it — and when not to

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 simply 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 — rebuild 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 — 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, completely free with no sign-up and no limits.

References

Documented against this tool's own 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 to JSON Converter online: fast, private and free for everyday document work.

DocumentOpen Tool
Popular

JSON to CSV Converter

Convert with JSON to CSV Converter, preserving structure and data, with zero uploads.

DocumentOpen Tool
Trending

Markdown to HTML

Markdown to HTML in seconds — accurate, free and processed locally in your browser.

DocumentOpen Tool

CSV to Excel Converter

Convert with CSV to Excel Converter, preserving structure and data, with zero uploads.

DocumentOpen Tool

Excel to CSV Converter

Excel to CSV Converter online: fast, private and free for everyday document work.

DocumentOpen Tool

Excel to JSON Converter

Convert with Excel to JSON Converter, preserving structure and data, with zero uploads.

DocumentOpen Tool

Ready to try the JSON Flattener?

It is free, private and runs entirely in your browser — no sign-up, no uploads, no limits.