UTILS.
100% in-browser
⊞}

JSON Flatten / Unflatten

Flatten nested JSON to dot-notation keys, or rebuild nested objects from flat keys.

— output appears here —

About this tool

JSON Flatten / Unflatten is a free, in-browser tool that converts nested JSON into a single-level map of dot-notation keys, and rebuilds the nested structure back from those flat keys. Paste JSON and choose a direction: Flatten collapses every path into one flat object (for example user.name or user.roles.0), while Unflatten expands dotted keys back into nested objects and arrays.

Both directions parse your input with the browser's own JSON parser and pretty-print the result with two-space indentation. Objects and arrays are walked recursively, array items keep their numeric index in the path, and leaf values — strings, numbers, booleans, null, and empty objects or arrays — are preserved unchanged. Invalid JSON shows an inline error instead of output, and a copy button puts the result on your clipboard.

Everything runs locally in JavaScript: no uploads, no accounts, no tracking, and it works offline. Flattening is handy for turning config into flat key/value pairs such as environment variables or i18n message files, for diffing deeply nested payloads, or for reshaping API responses, and unflattening reverses the same mapping.

Frequently asked questions

How are arrays handled?
Array elements use their numeric index in the key, like items.0.name. When unflattening, any path segment that is all digits is treated as an array index, so those parts are rebuilt as arrays.
Is my data uploaded?
No. Parsing and conversion run entirely in your browser's JavaScript, nothing is sent to a server, and the tool keeps working offline.
What happens to empty objects and arrays?
They are treated as leaf values and kept as-is at their key, so an empty {} or [] survives flattening unchanged rather than being expanded into deeper keys.
Does flatten then unflatten always return the original JSON?
Almost always, but two cases differ: a key that already contains a dot splits into extra nesting when unflattened, and an object key made only of digits is rebuilt as an array index instead of an object key.

More tools