Flatten JSON
POST
/v1/convert/flatten-json
curl -X POST "https://convert.toolkitapi.io/v1/convert/flatten-json" \
-H "X-API-Key: YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"json": {"user": {"name": "Alice", "address": {"city": "NYC"}}}}'
# See curl example
// See curl example
Response
200 OK
{
"json": {
"user.name": "Alice",
"user.address.city": "NYC"
},
"key_count": 2
}
How to Use
1
Send a POST request to /v1/convert/flatten-json with a json object and optional separator.
About This Tool
Flatten a nested JSON object into a single-level object with dot-notation keys. Nested objects use dots and array indices use brackets.
For example, {"a": {"b": [1, 2]}} becomes {"a.b[0]": 1, "a.b[1]": 2}. Configurable separator (default: dot).
Why Use This Tool
- CSV Preparation — Flatten nested JSON before converting to CSV for clean column headers.
- Search Indexing — Flatten nested documents for flat key-value search indices.
- Diff Comparison — Flatten two nested objects to easily compare all leaf values side by side.
Frequently Asked Questions
How are arrays handled?
Array elements use bracket notation: key[0], key[1], etc.
Can I use a custom separator?
Yes — pass a 'separator' parameter (e.g., '/' or '_') to replace the default dot notation.
Start using Flatten JSON now
Get your free API key and make your first request in under a minute.