What is a JSON Flattener?
Flatten a nested JSON payload into a single-level object when your next step is a CSV export, a spreadsheet, or a database column. Each leaf value ends up keyed by the full dotted path it came from, so nothing goes missing.
JSON is useful for hierarchical data, but downstream tools (Excel, SQL imports, a key-value store) often want a flat row. Flattening bridges the two without asking you to write a custom traversal.
BeautiCode's JSON Flattener handles deeply nested input, keeps array order via bracket indices, and produces dotted keys you can paste straight into a CSV header.
How to Use Our JSON Flattener
- Paste your nested JSON data into the input editor or use the sample data button
- The tool validates your JSON and displays any syntax errors immediately
- Click the "Flatten" button to convert nested structures into flat key-value pairs
- Review the flattened output using dot notation (e.g.,
address.city) and bracket notation for arrays - Copy the flattened JSON to clipboard or download it as a file
- Use the result in your data pipeline, spreadsheet import, or database operations
Examples
The flattener walks every key in the input and emits one entry per leaf value, with the full path joined by dots (and bracket indices for array items).
Example 1: Flatten a nested user profile
Address blocks and profile metadata are usually nested. Flattening makes each field its own column, ready for a spreadsheet.
Input
{
"user": {
"name": "Alice",
"address": {
"city": "Seoul",
"zip": "04524"
}
}
}Output
{
"user.name": "Alice",
"user.address.city": "Seoul",
"user.address.zip": "04524"
}Example 2: Array of items with indexed paths
Cart and invoice payloads nest arrays inside objects. Bracket indices in the output preserve the order while keeping the shape flat.
Input
{
"order": "ORD-001",
"items": [
{ "name": "Keyboard", "qty": 1 },
{ "name": "Mouse", "qty": 2 }
]
}Output
{
"order": "ORD-001",
"items[0].name": "Keyboard",
"items[0].qty": 1,
"items[1].name": "Mouse",
"items[1].qty": 2
}JSON specification reference
Quick reference from RFC 8259. The converter enforces these rules on input; anything outside them is rejected or normalized.
| Element | Meaning | Example |
|---|
| Object | Unordered set of key/value pairs | {"a": 1} |
| Array | Ordered list of values | [1, 2, "x"] |
| String | Unicode, double-quoted only | "hello" |
| Number | IEEE 754 double, no NaN / Infinity | 3.14 |
| Literal | true / false / null only | null |
Common invalid forms
{'a': 1} // single quotes not allowed
{a: 1} // unquoted keys
{"a": 1,} // trailing comma
NaN // not permitted by RFC 8259Key Features
Keys join with dots (user.address.city), arrays use bracket indices (items[0].name), and the original types (string, number, boolean, null) carry through without being stringified. Nesting depth is unbounded in practice, so you can feed it a verbose API response and still get a flat map back.
- Runs locally: Flattening executes in the browser, so the JSON you paste never gets sent over the network.
Frequently Asked Questions
Q: How does the flattener handle arrays inside nested objects?
Arrays within nested objects are flattened using bracket index notation combined with dot notation. For example, orders[0].items[2].price preserves both the array position and the full path hierarchy. This approach ensures every value in your JSON is represented as a unique key-value pair without any data loss, regardless of how deeply arrays and objects are interleaved.
Q: What delimiter is used for flattened key paths?
By default, nested keys are joined using dot notation (e.g.,address.city). Array indices are represented with bracket notation (e.g., items[0].name). This produces clear, readable key paths that reflect the original JSON hierarchy.
Q: Can I unflatten a flattened JSON back to its original structure?
The JSON Flattener focuses on converting nested structures into flat key-value pairs. While the tool does not provide an unflatten feature, the dot-notation keys preserve enough information about the original hierarchy to reconstruct the nested structure programmatically if needed.
Q: Are there any file size limitations?
There is no hard file size limit. Since all processing happens in your browser, the practical limit depends on your device's available memory. Most modern browsers can handle JSON files up to several megabytes without issues.
Q: How does flattening help with CSV or database imports?
Flattening converts hierarchical JSON into a single-level key-value structure, which maps directly to columns in a CSV file or database table. This eliminates the need for manual data extraction from nested objects before importing.