Skip to content
ToolShedby Wasim Shaikh

Flatten JSON

Flatten nested JSON objects and arrays into dot-notation key-value pairs, or unflatten them back into structured JSON.

Depth: 5
487 characters
Depth: 1 • 13 keys
Ready
View as a tree

Flatten & Unflatten Nested JSON Structures Effortlessly

Modern REST APIs, NoSQL documents, and GraphQL payloads frequently produce deep, multileveled hierarchies. When importing data into relational databases, analytics tables, CSV spreadsheets, or key-value stores, flattening complex structures into dot-notation paths makes records drastically easier to query, map, and process.

ToolShed's Flatten JSON & Unflatten JSON utility provides bidirectional transformation. Compress nested objects and arrays into simple flat properties, or rehydrate flat dot-delimited key paths back into pristine nested JSON objects.

Key Capabilities

Bidirectional Transformation

Toggle between Flatten (nested → flat) and Unflatten (flat → nested) with a single click.

Flexible Array Notations

Format array indices using standard dot notation (items.0.name) or programming brackets (items[0].name).

Configurable Delimiters

Support for standard dot (.), URL-style slash (/), underscore (_), colon (:), or custom separators.

Depth Control & Safety

Enforce a maximum flattening depth limit to prevent infinite recursion, while built-in prototype pollution guards protect your applications.

Related Data & JSON Tools

Explore companion utilities in the ToolShed workspace:

Frequently Asked Questions

What does flattening a JSON object mean?
Flattening converts a deeply nested JSON hierarchy into a single-level object where every property key is the full path of parent keys joined by a delimiter (typically a dot "."). For example, {"user": {"name": "Alice"}} becomes {"user.name": "Alice"}.
Can this tool unflatten flat JSON back into nested objects?
Yes. Switch the mode toggle to "Unflatten JSON" and paste your flat dot-notation keys. The tool will parse each key path, rebuild all intermediate objects and array indices, and output a clean, nested JSON structure.
How does it handle array indices when flattening?
You can choose between Dot notation (e.g., items.0.id) or Bracket notation (e.g., items[0].id). Both representations can be fully reversed when unflattening.
Can I choose custom delimiters instead of a dot?
Yes. You can select standard dot (.), slash (/), underscore (_), colon (:), or specify a custom delimiter character.
Can I limit how deep the flattener travels?
Yes. You can set a Maximum Depth limit (e.g., 1 or 2 levels). Any object or array deeper than your chosen depth will remain unflattened.
Is my JSON uploaded to any remote server?
No. All flattening and unflattening algorithms run 100% locally inside your web browser using native JavaScript. Your proprietary configurations, logs, and sensitive payloads remain completely on your machine.