Tools

Home
JSON FormatterSQL FormatterJS ValidatorMinify CSS
Merge PDFCompress PDFImage to PDF
JPG to PNGPNG to WebPCrop Image

Flatten JSON Object

Convert nested JSON objects to flat key-value pairs with dot notation, underscore, or slash separators

Your data never leaves your browser
JSON Input0 chars, 0 lines
Flattened Output0 chars, 0 lines
Ready·

Paste a nested JSON object, pick your separator (dot, underscore, or slash), and get a flat key-value structure back in one click. Useful when you need to dump API responses into spreadsheets, map deep configs to environment variables, or diff two payloads without chasing nested brackets. And everything runs in your browser. Nothing gets uploaded.

How It Works

Paste Nested JSON
→
Recursive Key Walk
→
Flat Key-Value Output

The tool walks every property in your JSON object. When it finds another object or array, it keeps going deeper and builds up the key path as it goes. Once it hits an actual value — a string, number, boolean, or null — it writes that value with the full concatenated path as the key. The separator you picked (dot, underscore, slash) joins each segment.

Examples

User Profile with Address

API returns a user object and you need it flat for a CSV export.

INPUT
{ "name": "Sara", "address": { "city": "Berlin", "zip": "10115" } }
OUTPUT
{ "name": "Sara", "address.city": "Berlin", "address.zip": "10115" }

E-commerce Order with Line Items

An order payload with an items array that you need flattened for a reporting dashboard.

INPUT
{ "order_id": 4021, "items": [ {"sku": "T-100", "qty": 2}, {"sku": "M-205", "qty": 1} ] }
OUTPUT
{ "order_id": 4021, "items.0.sku": "T-100", "items.0.qty": 2, "items.1.sku": "M-205", "items.1.qty": 1 }

Config File with Deep Nesting

A settings object four levels deep — common in app configs — flattened with underscore separators for environment variables.

INPUT
{ "db": { "primary": { "host": "10.0.0.1", "port": 5432 } } }
OUTPUT
{ "db_primary_host": "10.0.0.1", "db_primary_port": 5432 }

Who Uses This

💻 Backend Developers

Flatten API responses before inserting rows into flat database tables or sending data to analytics pipelines.

📊 Data Analysts

Turn nested JSON exports into flat structures that import cleanly into Excel or Google Sheets.

⚙️ DevOps Engineers

Convert nested config files to flat key-value pairs for environment variables or .env files.

🧪 QA Testers

Compare flattened versions of two API responses side-by-side to spot differences quickly.

Common Mistakes

Pasting an array instead of an object

If your top-level structure is [{...}, {...}], wrap it in an object first — {"data": [...]}. Flattening works on objects, not bare arrays.

Forgetting trailing commas break JSON

JavaScript lets you get away with trailing commas. JSON does not. Remove them before pasting or the parser will reject the input.

Picking the wrong separator for the target system

Dot notation is the default, but if your keys already contain dots (like "file.name"), switch to underscores or slashes so the flat keys don't become ambiguous.

Technical Details

Frequently Asked Questions

What does it mean to flatten a JSON object?

It means converting a multi-level nested object into a single-level object. Each key becomes the full path from the root. So {"user":{"name":"Jo"}} turns into {"user.name":"Jo"}. The values stay the same — only the structure changes.

Can I unflatten the result back to nested JSON?

Yes, but not with this particular tool. You'd need an unflatten tool that splits the dot-notation keys and rebuilds the hierarchy. The operation is reversible as long as the separator isn't also used inside the original key names.

Is my data safe when I paste it here?

Yes. The flattening runs entirely in your browser using JavaScript. Nothing is sent to any server. You can disconnect from the internet and it still works — that's how you know it is truly client-side.

Why would I flatten JSON instead of just parsing it normally?

Flat structures are easier to search, sort, and import. Spreadsheets need flat rows. Logging systems index flat keys faster. And comparing two objects field-by-field is simpler when every value sits at the top level.

Does flattening preserve arrays or just turn them into numbered keys?

Arrays become numbered keys. An array like ["a","b"] at path tags becomes {"tags.0":"a","tags.1":"b"}. You can choose between index notation and bracket notation (tags[0]) depending on what your target system expects.

Share: