How to use the JSON flattener
- Paste nested JSON into JSON. The root can be an object or an array.
- Set the Separator placed between path parts. The default is
.. - Pick how Array indexes look:
a.0(the separator again) ora[0](brackets). - Choose an Indent, then copy or download the Flat JSON, or read the key and value table under it.
What it does and when to use it
Nested JSON is natural for programs but awkward for tools that only understand one level of keys. Flattening helps when you:
- load records into a spreadsheet or CSV, where each column needs one name;
- compare two configs line by line, since every value now sits on its own line with its full path;
- write translation files for i18n libraries that use flat keys such as
checkout.button.pay; - build MongoDB
$setupdates or feature-flag keys that use dot paths.
Flat keys also make a document easy to search: find address.city once instead of scrolling through braces. To turn the flat object into environment variables, use JSON to .env; to reverse the process, use the JSON unflattener. The JSON key extractor lists the same paths in JavaScript accessor form, without building a new object.
How it works
The tool walks the parsed document depth-first and records each leaf value under the path it took to reach it. Object keys are joined with your separator; array positions are added either as plain numbers with the separator or as [n] with no separator before them. Strings, numbers, booleans and null are leaves. Empty objects and arrays are also stored as leaves so they are not lost. Keys come out in document order. A plain value at the root, such as 42, gives an object with an empty key.
All of this runs in your browser on the parsed value; nothing is uploaded.
Worked examples
{"user":{"name":"Asha","tags":["a","b"],"meta":{}},"active":true}
Default settings (separator ., indexes a.0), minified:
{"user.name":"Asha","user.tags.0":"a","user.tags.1":"b","user.meta":{},"active":true}
Separator / with a[0] indexes:
{"user/name":"Asha","user/tags[0]":"a","user/tags[1]":"b","user/meta":{},"active":true}
A root array [{"id":1},{"id":2}] gives {"0.id":1,"1.id":2}: the first path part is the item number.
Limits and tips
- Key clashes are flagged: a literal key containing the separator can collide with a nested path, only the last value survives, and a warning names the key.
- Large arrays produce one key per item, so a list of 10,000 records with 8 fields becomes 80,000 keys. For record lists, JSON to table is usually the better view.
Frequently asked questions
What happens to empty objects and arrays?
Can I get it back to the nested form?
Which separator should I use?
What if a key already contains a dot?
How do we know nothing is uploaded? Test it yourself on the privacy proof page.