TFT

JSON Flatten Tool – Flatten Nested JSON Online

Flatten deeply nested JSON into simple dot-notation key-value pairs. Our free JSON Flatten Tool makes complex data easier to process, store, and analyze in flat systems.

When to Use JSON Flatten

Your JSON has multiple levels of nesting that make it hard to work with in certain contexts. Database columns, form submissions, and environment variables all prefer flat key-value structures. Manually restructuring nested JSON is tedious and error-prone.

Database importsForm dataCSV conversionAnalyticsKey extraction

How Flattening Works

Before (Nested):

{
  "user": {
    "name": "John",
    "address": {
      "city": "NYC",
      "zip": "10001"
    }
  }
}

After (Flattened):

{
  "user.name": "John",
  "user.address.city": "NYC",
  "user.address.zip": "10001"
}

About JSON Flatten Tool

Nested JSON is great for structure but sometimes you need flat key-value pairs. This tool flattens nested objects by joining keys with a separator, turning deep structures into single-level objects. It also unflattens dot-notation keys back into nested JSON.

How flattening works

Paste your nested JSON and choose a separator like dot or underscore. Click Flatten and nested paths become single keys like user.address.city. Arrays get indexed keys like items.0.name. The result is a flat object with all values at the top level.

To unflatten, paste dot-notation JSON and click Unflatten. Keys like user.profile.name get rebuilt into nested objects. This is useful for converting between flat config formats and nested structures.

When you'd use this

Your database stores flat key-value pairs but your app uses nested JSON. Or you need to export nested config as environment variables. This tool also helps when working with form data that uses dot notation for nested fields.

Flattening loses some structure information. Arrays become indexed keys. Empty objects and null values need special handling. For complex structures, review the output to ensure it meets your needs.

Questions

What separators can I use?

Common choices are dot (.), underscore (_), or slash (/). Avoid separators that might appear in your keys naturally.

How are arrays handled?

Array items get numeric indices. An array item becomes items.0, items.1, etc. This preserves order when unflattening.

Can I flatten very deep objects?

Yes, but very deep nesting creates very long keys. Consider restructuring deeply nested data if possible.

Does unflatten work with any flat object?

Keys need to follow the dot-notation pattern. Random flat keys won't create meaningful nested structures.

What about empty objects or null?

Empty objects may disappear when flattening. Null values are preserved as explicit keys with null values.