Assoc Str
Add a string field to a dict, one key at a time
- dict
- dict
Assoc Str (associate string) is the workhorse of the pack's dict family: it takes an existing dict, adds one key with a string value, and hands back the updated dict. Chain several of them and you've hand-built a JSON object inside your workflow.
Why you'd reach for it
You're assembling structured data to send somewhere - a webhook body, an API call, a log line. Start with Empty Dict, then add fields one at a time: job_id, prompt, status. Each Assoc Str appends exactly one key. It's the visual-graph equivalent of writing d["key"] = "value", and it's the node you'll use most in this family because most metadata is text.
How it works
The implementation is a one-line dict spread: {**dict, key: value}. It copies the incoming dict, sets your key, returns the result. No mutation of the input, no surprises - pure function. The key and value are both plain string inputs you type in.
The inputs that matter
- dict (DICT) - the map you're building on. From Empty Dict or the output of another Assoc node.
- key (STRING) - the field name.
- value (STRING) - the field value.
- dict (DICT, output) - the updated map, ready to chain into the next assoc or into HTTP POST.
Installing it
Part of easy-comfy-nodes. ComfyUI Manager: search easy-comfy-nodes. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/wmatson/easy-comfy-nodes
# restart ComfyUI
Where people get burned
- Everything is a string.
Assoc Strstores exactly what you type, so"3"stays text. If your downstream consumer (a webhook handler, an API) expects a real integer or boolean, you'll have to coerce it on the receiving end. The pack's assoc family is typed by what the value is - string, dict, or image - not by JSON types, and there's no int node here. - Duplicate keys overwrite. Set
keyto the same name twice and the second wins, because it's just a dict spread. That's occasionally what you want, and occasionally a silent bug. - Long chains get wide. Twenty assoc nodes in a row is a lot of graph real estate. If your payload is genuinely complex, building it in a script and posting it via the API is often cleaner - these nodes shine for small, readable metadata blocks.
The honest take: this is a plumbing node. It's not glamorous, but it's the difference between "ComfyUI can't send structured data anywhere" and "my workflow can POST a JSON payload." Once you're building automation around ComfyUI, you'll use it constantly.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| dict | DICT | — | |
| key | STRING | — | |
| value | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| dict | DICT | — |