Last updated
Example: Deep Nesting
// Input (5 levels deep):
{
"a": {
"b": {
"c": {
"d": {
"e": "deep value"
}
}
}
}
}
// Output:
{
"a.b.c.d.e": "deep value"
}
Example: Array Flattening with Bracket Notation
// Input:
{
"order": {
"id": "ORD-001",
"items": [
{ "product": "Widget", "qty": 2, "price": 10.00 },
{ "product": "Gadget", "qty": 1, "price": 25.00 }
]
}
}
// Output (bracket notation for arrays):
{
"order.id": "ORD-001",
"order.items[0].product": "Widget",
"order.items[0].qty": 2,
"order.items[0].price": 10.00,
"order.items[1].product": "Gadget",
"order.items[1].qty": 1,
"order.items[1].price": 25.00
}
Example: API Response Flattening
// Input (GitHub API user response):
{
"login": "octocat",
"id": 1,
"name": "The Octocat",
"company": "GitHub",
"location": "San Francisco, CA",
"public_repos": 8,
"followers": 20000,
"plan": {
"name": "pro",
"space": 976562499,
"private_repos": 9999
}
}
// Output (flattened):
{
"login": "octocat",
"id": 1,
"name": "The Octocat",
"company": "GitHub",
"location": "San Francisco, CA",
"public_repos": 8,
"followers": 20000,
"plan.name": "pro",
"plan.space": 976562499,
"plan.private_repos": 9999
}
Key Separator Options
// Same nested object with different separator styles:
Input: { "user": { "first_name": "Alice" } }
Dot notation (default):
"user.first_name": "Alice"
Underscore notation:
"user_first_name": "Alice"
Bracket notation:
"user[first_name]": "Alice"
Double underscore:
"user__first_name": "Alice"
Example: CSV Export After Flattening
// Input JSON array:
[
{ "name": "Alice", "address": { "city": "New York", "zip": "10001" } },
{ "name": "Bob", "address": { "city": "Chicago", "zip": "60601" } },
{ "name": "Carol", "address": { "city": "Austin", "zip": "73301" } }
]
// Flattened:
[
{ "name": "Alice", "address.city": "New York", "address.zip": "10001" },
{ "name": "Bob", "address.city": "Chicago", "address.zip": "60601" },
{ "name": "Carol", "address.city": "Austin", "address.zip": "73301" }
]
// CSV export:
name,address.city,address.zip
Alice,New York,10001
Bob,Chicago,60601
Carol,Austin,73301
Example: Unflattening (Reverse Operation)
// Input (flat key-value pairs):
{
"database.host": "localhost",
"database.port": 5432,
"database.credentials.user": "admin",
"database.credentials.password": "secret",
"server.port": 8080,
"server.debug": true
}
// Output (unflattened / nested):
{
"database": {
"host": "localhost",
"port": 5432,
"credentials": {
"user": "admin",
"password": "secret"
}
},
"server": {
"port": 8080,
"debug": true
}
}
Flattening Statistics
Input JSON:
Original keys: 8
Max nesting depth: 4
Arrays found: 2 (with 5 total items)
Output (flattened):
Flattened keys: 23
Key expansion: +15 keys (from array flattening)
Schema inference:
string fields: 12
number fields: 8
boolean fields: 2
null fields: 1
Null Value Handling
// Input:
{
"user": {
"name": "Alice",
"middleName": null,
"age": 30
}
}
// Output (null preserved):
{
"user.name": "Alice",
"user.middleName": null,
"user.age": 30
}
// CSV output (null as empty cell):
user.name,user.middleName,user.age
Alice,,30
Paste your nested JSON to flatten it into dot-notation key-value pairs. Use the CSV export to open the data directly in Excel or Google Sheets.
Example: Basic Object Flattening
// Input (nested):
{
"user": {
"name": "Alice",
"age": 30,
"address": {
"city": "New York",
"zip": "10001",
"country": "US"
}
}
}
// Output (flattened with dot notation):
{
"user.name": "Alice",
"user.age": 30,
"user.address.city": "New York",
"user.address.zip": "10001",
"user.address.country": "US"
}