ComfyUI Node

Assoc Dict

Nest a whole dict inside another dict

By wmatson·Created 3 years ago·Updated about a year ago· 18
Assoc Dict
  • dict
  • value
  • dict
key

Assoc Dict is the nested-structures member of the pack's dict family. Where Assoc Str adds a string field, this one adds an entire dict as the value of a key - letting you build JSON with depth: {"job": {"id": "abc", "status": "done"}} instead of a flat pile of strings.

Why you'd reach for it

Real payloads are rarely flat. A webhook body for a generation service might want {"result": {"image_url": "...", "seed": 42, "params": {...}}}. That nesting is exactly what this node is for: build the inner dict with its own Empty Dict + Assoc chain, then attach it to a key of the outer dict. Combined with Assoc Str, you can express arbitrarily deep structures - the graph just gets busier the deeper you go.

How it works

Same one-liner as the string variant: {**dict, key: value}. The only difference is the value input is typed DICT instead of STRING, so it has to come from another dict-producing node - you can't just type a value in. That's a feature: it forces you to build nested structures explicitly, which keeps the graph honest about what's in your payload.

The inputs that matter

  • dict (DICT) - the outer map you're extending.
  • key (STRING) - the field name to set.
  • value (DICT) - the nested map. Wire in the output of another Empty Dict / Assoc chain.
  • dict (DICT, output) - the outer map, now with the nested structure attached.

Installing it

Part of easy-comfy-nodes. ComfyUI Manager: search easy-comfy-nodes. Or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/wmatson/easy-comfy-nodes
# restart ComfyUI

Where people get burned

  • Nothing is typed in. The value input is a wire, not a text box. Beginners try to paste JSON into it and get confused. Think of it as "attach a sub-map," not "paste an object."
  • Graph sprawl. Every level of nesting is another Empty Dict plus assoc nodes. A payload three levels deep is ten-plus nodes of pure plumbing. It works, it's readable, and it's verbose. For really complex bodies, generate the JSON in a script instead.
  • The flat-string trap. If you build everything with Assoc Str, your JSON stays flat and string-typed. This node is how you escape that - it's the only way to get real nesting out of the family.

Pair it with Empty Dict (to start inner maps) and Assoc Str (for leaf values), and terminate the whole chain at HTTP POST to send the finished structure somewhere. It's plumbing, but it's the plumbing that makes "send structured data from a workflow" a thing ComfyUI can do at all.

CategoryDICT

Inputs (3)

NameTypeDefaultDescription
dictDICT
keySTRING
valueDICT[object Object]

Outputs (1)

NameTypeDescription
dictDICT