JsonUnflatten (Yogurt Nodes)
Reassemble flat keys into the nested JSON you actually wanted
- flat_json
- nested_json
JsonFlatten is the "make it flat so I can work with it" node; JsonUnflatten is the "now give it back" half. Feed it {"settings.model": "xl", "settings.steps": 20, "items.0.name": "ada"} and it rebuilds the nested object - {"settings": {"model": "xl", "steps": 20}, "items": [{"name": "ada"}]} - complete with arrays where the keys imply them.
It's a logic node in the YogurtNodes pack (yogurt7771/ComfyUI-YogurtNodes), the round-trip partner to Flatten. Where that round trip matters: you flatten a config so an LLM can see/edit it as a linear list of key = value lines, then unflatten the edited version back into structured form for an API call.
How it works
It splits each flat key on separator (default .) and rebuilds the hierarchy, nesting dicts along each path. The clever bit is auto_detect_arrays (default on): a segment that looks like an integer index - items.0, items.1 - becomes an array element instead of a dict key. So items.0.name builds a list, not a dict with a key literally named "0". Turn auto_detect_arrays off and every segment stays a dict key, which is what you want when your keys are genuinely numeric-named.
Two things to keep straight so the round trip survives:
- The
separatormust match what Flatten used. Flatten with.and unflatten with>and your keys come back looking like"settings>model"- a wrong separator quietly produces garbage that looks right at a glance. - Flatten's
include_arrayssetting must be consistent too. If you flattened with arrays included and unflatten with auto-detect on, the round trip is clean. Mixed settings and your structure won't reassemble.
Inputs that matter
flat_json- the flat object with dotted keys.separator- must match the flatten side.auto_detect_arrays- on by default; off only when integer segments are legitimately dict keys.
Output: nested_json.
Install
Pack-wide routine - ComfyUI Manager (search "YogurtNodes") or:
cd ComfyUI/custom_nodes
git clone https://github.com/yogurt7771/ComfyUI-YogurtNodes.git
cd ComfyUI-YogurtNodes
pip install -r requirements.txt
Restart, find it under Yogurt Nodes / Logic. No extra dependencies.
Troubleshooting
- "The round trip doesn't match what I started with." Separator mismatch is the #1 cause.
a.bflattened with.must be unflattened with.; the moment either side changes, keys collide or come back flat. - "My arrays came back as weird dicts." That's
auto_detect_arraysbeing off, or the flattened keys not being plain integer indices. Mixeditems.0anditems.fooin the same key is ambiguous - arrays need consecutive integer segments to be reliable. - Duplicate-ish keys. Two flat keys that collapse to the same path (
a.banda.bfrom different sources) - last one wins, quietly. Deduplicate before unflattening if you care. - Sparse arrays.
items.0anditems.5rebuild as a list with gaps or padding behavior depending on implementation. Keep indices dense unless you don't care about the holes.
The mental model: Flatten turns structure into a sortable, editable, LLM-friendly list. Unflatten turns it back into structure. Use them as a matched pair and you get the best of both - human-readable editing of deeply nested config without ever hand-editing a brace.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| flat_json | * | Flattened JSON object | |
| separatoropt | STRING | . | Separator used in flattened keys |
| auto_detect_arraysopt | BOOLEAN | true | Automatically detect and create arrays |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nested_json | * | — |