JSON Flatten / Unflatten

Flatten nested JSON objects to dot-notation keys or unflatten them back.

POST 1 credit /v1/json-flatten
curl -X POST "https://devtools.toolkitapi.io/v1/json-flatten" \
  -H "Content-Type: application/json" \
  -d '{
    "data": {
      "user": {
        "name": "Alice",
        "address": {"city": "Portland", "zip": "97201"}
      }
    },
    "separator": ".",
    "direction": "flatten"
  }'
import httpx

resp = httpx.post(
    "https://devtools.toolkitapi.io/v1/json-flatten",
    json={
    "data": {
      "user": {
        "name": "Alice",
        "address": {"city": "Portland", "zip": "97201"}
      }
    },
    "separator": ".",
    "direction": "flatten"
  },
)
print(resp.json())
const resp = await fetch("https://devtools.toolkitapi.io/v1/json-flatten", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "data": {
      "user": {
        "name": "Alice",
        "address": {"city": "Portland", "zip": "97201"}
      }
    },
    "separator": ".",
    "direction": "flatten"
  }),
});
const data = await resp.json();
console.log(data);
# See curl example
Response 200 OK
{
  "result": {
    "user.name": "Alice",
    "user.address.city": "Portland",
    "user.address.zip": "97201"
  },
  "direction": "flatten",
  "key_count": 3
}

Try It Live

Live Demo

Description

Flatten nested JSON objects to dot-notation keys or unflatten them back.

How to Use

1

1. Pass your JSON object in the `data` field. 2. Set `direction` to `flatten` (default) or `unflatten`. 3. Optionally change the `separator` (default is `.`).

About This Tool

JSON Flatten converts deeply nested JSON objects into flat key-value maps using dot-notation (or a custom separator). Unflatten does the reverse — rebuilding nested structures from flat keys.

Useful for config management, database storage, CSV export, and comparing nested objects by their leaf values.

Why Use This Tool

Frequently Asked Questions

How are arrays handled during flatten?
Arrays are flattened with numeric indices: `items.0.name`, `items.1.name`. Nested objects inside arrays are recursively flattened.
Can I use a different separator?
Yes — set `separator` to any string up to 10 characters, e.g. `__` or `/`.

Start using JSON Flatten / Unflatten now

Get your free API key and make your first request in under a minute.