Nodes/Quality of Life Nodes for ComfyUI/JSON Chain Object Pair (Soze)
ComfyUI Node

JSON Chain Object Pair (Soze)

Nesting JSON the ComfyUI way — objects inside objects

By SozeInc·Created 2 years ago·Updated 8 days ago· 10
JSON Chain Object Pair (Soze)
  • nested_chain
  • chain_in
  • chain_out
name

Flat JSON gets you only so far. Real API payloads nest: a meta block with a dozen keys, a settings object holding your sampler config, a generation object wrapping everything else. JSON Chain Object Pair (Soze) is the node that adds a level of nesting to the Soze JSON chain - and because object pairs can contain other object pairs, it lets you build trees of arbitrary depth without ever hand-writing a bracket.

This is the node that makes the rest of the JSON family feel like a real system. You build a separate side-chain of pair nodes (any mix), feed its chain_out into nested_chain, and all those pairs collapse into a single nested object under the name you type. Meanwhile chain_in keeps the outer chain flowing. Same node, two chain ports - the mental model is "what's on top of me" vs "what goes inside me."

How it works

On execution it takes whatever side-chain arrives at nested_chain (or nothing, for an empty object), collapses the (key, value) tuples into a dict, and appends (name, nested_object) to the outer chain. There's no depth limit in the code - an Object Pair's nested chain can itself contain an Object Pair - so you can build {"a":{"b":{"c":…}}} as a stack of these nodes. Blank keys in the nested chain are skipped, same as everywhere else in the family.

Inputs and outputs

  • name - required string widget, the key the nested object lands under.
  • nested_chain - optional JSON_PAIRS. The side-chain whose pairs become the object's keys/values.
  • chain_in - optional JSON_PAIRS. The outer chain this property is appended to.

Output: chain_out. A practical example - a meta block:

String Pair("title", "My Image")
  └─ Object Pair("meta")
        ├─ nested: String Pair("model", "flux")
        ├─ nested: Int Pair("seed", 1234)
        └─ nested: Float Pair("cfg", 3.5)
→ JSON Generate

{"title":"My Image","meta":{"model":"flux","seed":1234,"cfg":3.5}}.

Installing it

Part of the Soze pack:

cd ComfyUI/custom_nodes
git clone https://github.com/SozeInc/ComfyUI_Soze.git
pip install -r ComfyUI_Soze/requirements.txt

Restart ComfyUI, or search ComfyUI_Soze in ComfyUI Manager.

Gotchas

The most common stumble is wiring the chain backwards - feeding the side-chain into chain_in and the outer chain into nested_chain, which produces nested garbage. nested_chain is only for the sub-object's pairs. Also remember the sub-chain doesn't have to come from a single node: chain ten String Pairs into a String Pairs (10X)-style block, or even another Object Pair, and the whole thing nests correctly. If your final JSON looks flat or wrong, check which port each chain is actually on.

CategorySoze Nodes/JSON

Inputs (3)

NameTypeDefaultDescription
nameSTRING
nested_chainoptJSON_PAIRSSide-chain whose pairs become the nested object's keys/values.
chain_inoptJSON_PAIRSOuter chain this property is appended to.

Outputs (1)

NameTypeDescription
chain_outJSON_PAIRS