What is a JSON Flattener?
A JSON flattener converts a nested JSON object into a single-level object whose keys are the full path to each value, so {"user":{"city":"Austin"}} becomes {"user.city":"Austin"}. Arrays flatten the same way, using the index as a path segment: {"roles":["admin","editor"]} becomes {"roles.0":"admin","roles.1":"editor"}. The result is a flat map of path to leaf value with no remaining nesting.
Flattening is how you get deeply nested API responses and config files into formats that only understand flat key-value pairs. Spreadsheet columns, environment variables, dotted i18n message keys, feature-flag stores, and many logging and analytics pipelines all expect one level of keys, and a dotted path such as user.address.city is the standard way to carry the original structure through them. The reverse operation, unflatten, rebuilds the nested object and its arrays from those dotted keys, so the transform is a lossless round trip in both directions.
This tool runs entirely in your browser. It parses the JSON, walks it to leaf values, and serialises the flat or nested result without sending anything to a server. Nothing is uploaded, logged, or stored, which keeps payloads with tokens, IDs, or personal data on your machine, and the tool keeps working offline once the page has loaded.
Flattening trades structure for a shape that spreadsheets, form encoders and environment variables can carry, and the round trip is lossless in both directions provided one thing holds: your keys must not already contain the delimiter. A key named "user.name" flattened with a dot is indistinguishable from a nested object, and unflattening will turn it into one. Change the delimiter to something the data does not use when that is a risk. Array indices become numeric path segments, so items.0.id addresses the first element, and an unflattener has to decide whether a numeric key means an array or an object with numeric keys. Empty objects and empty arrays are preserved explicitly rather than dropped, since losing them would change the meaning of a config file.
How to use the JSON Flattener?
Choose flatten or unflatten
Flatten turns nested JSON into dotted keys. Unflatten rebuilds nested objects and arrays from dotted keys. Load the sample to see both directions.
Paste your JSON
Paste a nested object to flatten, or a flat object with dotted keys to unflatten. The input must be valid JSON; parse errors are reported with the exact position.
Set the key style
Pick the delimiter, usually a dot, and choose dot (roles.0) or bracket (roles[0]) notation for array indices. Keep the same settings for both directions so the round trip matches.
Copy or download the result
Press the action button, then copy the output to your clipboard or download it as a .json file. The key count confirms how many leaves were produced.
Key Features
Lossless flatten and unflatten
Flatten a nested object, then unflatten the result, and you get the original back, including arrays, nulls, booleans, and empty containers. The two operations are exact inverses.
Array-aware paths
Array items keep their index in the path, so order survives the round trip. Choose dot notation (items.0.id) or bracket notation (items[0].id) to match the system you are feeding.
Configurable delimiter
Use a dot by default, or switch to another separator when your target keys already contain dots. The same delimiter drives both flatten and unflatten.
Empty containers preserved
An empty object or empty array is kept as a leaf value rather than silently dropped, so a config that relies on an empty list still round-trips correctly.
Frequently Asked Questions
Related Tools
JSON Schema Generator
Generate a JSON Schema from any JSON sample. Infers types, merges arrays of objects into one item schema, derives required fields, and detects date-time, email, uri, and uuid formats. Draft-07 and 2020-12 output. 100% client-side.
JSON Sorter
Sort the keys of a JSON object alphabetically, recursively through nested objects, with optional array sorting. Ascending or descending, minify or pretty. Client-side, no signup.
JSON to TypeScript
Generate TypeScript interfaces from any JSON sample. Infers nested types, merges arrays of objects into a single interface, marks nullable and missing keys optional, and emits clean exportable code. 100% client-side.
JSON to YAML Converter
Convert JSON to clean, valid YAML instantly - configurable indentation and safe string quoting
Comments
0 comments
No comments yet. Be the first to share your thoughts!