JSON Flatten Tool
Flatten nested JSON into dot-notation keys and unflatten back with configurable array notation, delimiters, and array handling.
Updated
What is the JSON Flatten Tool?
JSON Flatten Tool converts deeply nested JSON objects into single-level dot-notation keys (like user.address.city) and reverses the process back to nested structures. It supports bracket array notation (tags[0]) or dot-style (tags.0), custom delimiters, and two array strategies: expand arrays into indexed paths or preserve them intact. All work happens instantly in your browser with no server upload, giving you live statistics on key count, nesting depth, and array usage.
How it works
Paste any JSON object or array. The tool walks every leaf value recursively and builds a flat Record<string, unknown> where each key is the full path joined by your delimiter. Arrays are handled according to your strategy:
- Expand creates indexed paths like
tags[0]ortags.0. - Preserve keeps the array as a leaf value at its parent key (e.g.,
"tags": ["dev", "admin"]).
Empty arrays in expand mode produce no keys. Nested objects inside arrays continue to flatten correctly (items[0].name).
Unflatten Mode
Paste a flat JSON object. The parser splits each key by the delimiter. Numeric segments are interpreted as array indices when using dot-style (tags.0.name); bracket segments (tags[0]) are parsed as property + index pairs. The tool rebuilds nested objects and arrays, throwing clear errors if it detects ambiguous paths (e.g., a key is both a leaf and a parent).
Options
- Delimiter: any string (
.,_,/,-, or custom). - Array index style: bracket (
items[0]) or dot (items.0). - Array strategy: expand into indexed keys or preserve arrays intact.
- Output format: pretty-printed or compact JSON.
Results update instantly as you type.
Examples
Flatten nested object
Convert nested user profile to flat keys
Unflatten with arrays
Rebuild nested structure from flat keys including array indices
Frequently asked questions
What array notations are supported?
What array notations are supported?
Both bracket (tags[0]) and dot (tags.0) styles are supported for array indices.
Can I use a custom delimiter?
Can I use a custom delimiter?
Yes. You can set any delimiter string such as underscore (_), slash (/), or dash (-).
What does "Preserve arrays" do?
What does "Preserve arrays" do?
It keeps arrays as leaf values instead of expanding them into individual indexed keys.
Why does unflatten throw an ambiguous path error?
Why does unflatten throw an ambiguous path error?
This happens when a flat key tries to make a value both a leaf and a parent (for example, a.b exists as a leaf while a.b.c also exists).
Does this send my data to a server?
Does this send my data to a server?
No. All processing is done entirely in your browser. No data is uploaded or stored externally.
Can I flatten arrays at the root level?
Can I flatten arrays at the root level?
Yes. Root-level arrays are supported; expand mode produces keys like [0], 1, etc., or 0, 1 depending on array style.
Related tools
More utilities you might find handy.
.env File Generator
Quickly generate clean, properly-quoted .env files from key-value pairs — no more quoting errors or broken deployments.
.htaccess Redirect Builder
Generate error-free Apache .htaccess code for 301 redirects, HTTPS enforcement, and canonical URL routing.
ASCII Converter – Text to ASCII, Hex, Binary & Back
Convert text to ASCII codes and decode back in decimal, hex, binary, or octal — live, private, and 100% browser-based.