JSON Unflatten Utility
Reconstruct deeply nested JSON objects and arrays from flat delimited key-value dictionaries. Supports dot notation, brackets, automatic array synthesis, and 100% in-browser privacy.
items.0)Recursion Depth Safety Cap: 50 LevelsReconstructing Hierarchical State from Flat Data Sources
Modern software engineering constantly shuttles data between flat tabular representations and deeply nested object graphs. Relational database tables, CSV spreadsheets, and HTML form submissions serialize complex records into flat key-value pairs. However, backend domain models, GraphQL schemas, and modern frontend frameworks (React, Vue, Svelte) demand structured, hierarchical object trees.
JSON Unflattening is the algorithmic reverse process of JSON flattening. It parses delimited string keys—such as "billing.address.postal_code" or "line_items[0][price]"—and reconstitutes the authentic multi-tier tree structure with appropriate nested dictionaries and arrays.
This JSON Unflatten Tool provides an automated, zero-upload client-side engine that parses flat dictionaries and regenerates pristine, nested JSON trees adhering to enterprise structural standards.
Path Tokenization Paradigms: How Keys Are Decomposed
The unflattening pipeline begins with lexical path tokenization. The algorithm must accurately slice path strings into individual segment tokens regardless of delimiter styling:
| Input Key Format | Path Delimiter | Extracted Token Segments | Synthesized Hierarchy |
|---|---|---|---|
user.profile.bio | Dot notation (.) | ["user", "profile", "bio"] | { user: { profile: { bio: ... } } } |
orders[0][total] | Bracket notation ([]) | ["orders", "0", "total"] | { orders: [{ total: ... }] } |
geo/coordinates/lat | Slash (/) | ["geo", "coordinates", "lat"] | { geo: { coordinates: { lat: ... } } } |
app_config_debug | Underscore (_) | ["app", "config", "debug"] | { app: { config: { debug: ... } } } |
Heuristics for Array vs. Object Reconstruction
A central challenge in unflattening logic is deciding when a numeric key segment should synthesize a JavaScript Array ([...]) versus a plain Object ({ ... }).
Our engine employs a robust two-pass heuristic:
- Initial Tree Construction: The parser traverses the token segments from left to right. When navigating to an uninitialized child node, it checks whether the subsequent token is composed purely of digits (e.g.
"0","1"). If numeric, it initializes an empty array; otherwise, an empty object. - Array Normalization Pass: Once all keys are populated, the engine recursively inspects all objects in the tree. If an object's keys consist exclusively of contiguous integers starting at index
0(e.g.["0", "1", "2"]), the engine converts the container into a true native array. If keys have gaps (e.g.["0", "4", "9"]) or contain alphanumeric names, it safely retains the container as an object to avoid sparse arrays with hundreds of empty slots.
Security: Prototype Pollution Prevention and Depth Caps
When deserializing untrusted flat keys into nested objects, naive recursive assignment can expose critical security vulnerabilities:
1. Prototype Pollution Defense
If a malicious user submits keys like "__proto__.isAdmin" or "constructor.prototype.debug", a naive tree traversal will mutate JavaScript's global Object.prototype. This can lead to privilege escalation, arbitrary code execution, or denial of service across all objects in the runtime.
Our engine explicitly guards against prototype pollution by skipping dangerous property names (__proto__, prototype, constructor) during traversal, ensuring absolute runtime security.
2. Recursion Depth Cap (50 Levels)
Deeply crafted keys like "a.b.c.d.e..." containing hundreds of segments can trigger browser call stack overflow crashes. Per our engineering directives, this tool enforces a hard safety limit of 50 recursion levels, truncating pathological depths safely without sacrificing real-world schema fidelity.
Typical Production Integration Scenarios
- Hydrating Web Form Data: When an HTML form submits fields named
address[street],address[city], andaddress[state], unflattening merges these scattered form inputs into a structuredaddressobject for API persistence. - Ingesting Denormalized SQL Queries: Relational SQL joins frequently output flat rows with aliased column names (e.g.
customer_name,order_id,order_item_sku). Unflattening converts tabular query results into rich nested domain entities. - Reverse ETL Pipelines: Extracting flat records from columnar warehouses (Snowflake, Databricks) and restoring original nested documents for sync back into MongoDB or DynamoDB collections.
Zero-Knowledge Architecture: 100% In-Browser Privacy
Enterprise software schemas frequently contain sensitive organizational models, private database keys, and proprietary payload structures. 2ClickKit ensures absolute privacy by processing all JSON documents directly within your client web browser. No data packets are ever transmitted across the internet, logged in external caches, or stored on third-party infrastructure.
How to Use How to Unflatten JSON into Nested Objects
-
Paste Flattened JSON Payload
Paste any single-level flattened JSON document containing delimited keys into the input editor.
-
Select Path Delimiter Strategy
Choose Auto-Detect (default) or explicitly select dot notation (user.name), bracket notation (user[name]), underscores, or slashes.
-
Automatic Array & Object Synthesis
The client-side engine reconstructs contiguous numeric keys (items.0, items.1) into true arrays and expands object branches recursively.
-
Copy Nested JSON or Download .json
Copy the fully restored multi-tier JSON tree directly to your clipboard or download as a .json file.
Technical Specifications
- Supported Inputs: Text, Files, Raw Data
- Input Limit: No strict limit (Client-side execution)
- Processing Engine: 100% In-Browser (Client-Side Execution)
- Content Uploads: None (Your files and text are processed locally on your device with zero uploads)
Privacy & Security Guarantee
Your files and text content are processed entirely in your web browser's memory using native client-side web technologies. Unlike traditional cloud tools, your content is never uploaded to remote servers, stored on external disks, or analyzed by third parties.
2ClickKit In-Browser vs Traditional Cloud Tools
| Feature | 2ClickKit (In-Browser) | Traditional Cloud Services |
|---|---|---|
| Data Privacy | Files never leave your local device | Uploaded to remote servers and third-party clouds |
| Processing Speed | Instant local execution (0ms upload time) | Constrained by internet upload & server processing queues |
| Account & Costs | 100% Free with zero registration or paywalls | Tiered subscriptions, limits, or forced sign-ups |
Best Practices & Tips
- Use Auto-Detect if your keys mix dot notation and brackets: user[profile].email is parsed cleanly.
- Verify sequential indices: ensure array keys start at 0 and have no gaps for clean array synthesis.
- Export flattened SQL query results as JSON and unflatten them into rich entity trees for frontend apps.
- Pair this tool with our companion JSON Flatten tool for reliable round-trip schema manipulation.
Frequently Asked Questions
What does it mean to 'unflatten' a JSON object?
Unflattening reverses a flattened single-level dictionary into a deep, hierarchical JSON tree structure. Delimited keys such as 'user.contact.email' are tokenized and expanded into nested object containers: {'user': {'contact': {'email': '...'}}}.
How does the tool reconstruct arrays from flattened keys?
When path tokens consist solely of sequential zero-based integers (such as 'tags.0', 'tags.1', 'tags.2'), the engine automatically synthesizes a true JSON array: {'tags': ['val0', 'val1', 'val2']}. If indices are non-contiguous or mixed with text strings, the engine safely preserves them as object keys to prevent accidental data corruption.
What delimiters are supported for unflattening?
The tool supports dot notation ('.'), bracket notation ('[key]'), underscores ('_'), and forward slashes ('/'). The Auto-Detect option inspects keys and automatically chooses the appropriate delimiter parser.
How does the tool protect against deeply nested payloads or prototype pollution?
The unflattening algorithm enforces a strict 50-level recursion cap to guard against call stack overflows. Furthermore, it explicitly sanitizes object prototypes, preventing dangerous prototype pollution attacks (such as malicious '__proto__' or 'constructor' keys) from affecting your runtime environment.
Can I convert flattened CSV exports back into nested JSON?
Yes! If you convert a CSV spreadsheet into a flat JSON object (where column headers represent dot-separated paths like 'shipping.address.zip'), this tool will reconstruct the original hierarchical JSON entity tree perfectly.
Is there any data size limit?
Because processing runs entirely client-side using browser memory buffers, the tool comfortably unrolls documents containing thousands of keys in milliseconds without network timeouts.
Is any of my JSON data transmitted over the internet?
No. 2ClickKit executes 100% locally in your web browser. Zero network requests or tracking analytics are dispatched, guaranteeing absolute privacy for confidential enterprise data.