JSON Flatten

Flatten nested JSON to dot-notation keys or unflatten back to nested structure. Handle arrays, null values, custom separators.

Separator:Arrays:

What Is JSON Flattening?

JSON flattening converts a nested object into a flat key-value map where keys are paths in dot notation. {"user": {"name": "Alice", "address": {"city": "NYC"}}} becomes {"user.name": "Alice", "user.address.city": "NYC"}. Each leaf value gets a key that describes its full path in the original structure.

Flattening is useful for environment variable configs (where nested keys become FLAT_KEY_FORMAT), for storing JSON in key-value databases, and for diffing or iterating over all values with their paths. Unflattening reverses the process to restore the nested structure.

How to Use This JSON Flatten Tool

Paste your JSON into the input area. Choose Flatten or Unflatten mode. For flattening, select the separator (dot, slash, underscore) and array notation (index like arr.0 or bracket like arr[0]). Click Process to see the result.

The tool shows before/after with syntax highlighting, key count, and max depth. Use Copy to copy the output. For unflattening, ensure your flat keys use the same separator you selected.

Array and Nested Structure Handling

Arrays are flattened by index: {"items": ["a", "b"]} becomes {"items.0": "a", "items.1": "b"} with dot notation. Nested arrays work the same: {"matrix": [[1,2],[3,4]]} becomes matrix.0.0, matrix.0.1, etc. Mixed objects and arrays are supported. Null values are kept. The max depth and key count help you understand the structure's complexity.

Frequently Asked Questions

Related Tools

Explore More Tools

Find this tool useful? Buy us a coffee to keep DuskTools free and ad-light.