string → Dict🗂️
Your prompts, one key at a time
- dict
- dict
This is the node that makes the whole pack worth installing. DictAddString ("string → Dict🗂️") is the one you'll reach for first, because text is the thing you most want to organize in a ComfyUI graph. Instead of dragging a prompt string halfway across the canvas to every node that needs it, you drop it into a dictionary under a key, and the dict travels as a single wire.
The idea is simple: a dict is just a box with named slots. You put a chunk of text in slot positive, another in slot subject, another in style. Later - anywhere downstream - you pull a value back out by name with a DictExtractString node and wire it into a CLIP Text Encode or a StringConstructor formatter. One fat wire instead of six thin ones is the whole pitch, and it works.
What you actually set
- key - the name of the slot.
positive,negative,subject, whatever you'll remember later. - value - the text itself. It's a multiline field, so paragraph-size prompts are fine.
- cleanup_key (on by default) - strips leading/trailing spaces and extra newlines from the key. The upshot:
"positive "and"positive"are the same key, which saves you from a class of "why is my key missing" bugs. - cleanup_value (on by default) - strips the leading/trailing whitespace from each line of the value. Leave it on; it's doing tidy work you'd otherwise do by hand.
- dict (optional) - feed in an existing dictionary and this node adds to it, returning a new combined dict. Leave it unconnected and you start a fresh dict with just this one entry.
Output is a single dict wire. That's the whole thing - one output, chainable.
How it behaves under the hood
A couple of quirks are worth knowing so they don't surprise you. The dict comes back as a frozendict (immutable), which is deliberate: it means two downstream branches can consume the same dict wire without any of them silently mutating the shared data. Keys are also kept alphabetically sorted, so don't expect your dict to remember the order you added things - lookups are by name, not position, so it never matters for extraction.
Install
It's the same for every node in this pack - a tiny, focused pack by Lex Darlog with exactly one dependency (frozendict, a small pure-Python package), no model downloads, no heavy wheels. Via ComfyUI Manager, search "Dict Tools" and install. Or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/Lex-DRL/ComfyUI-DictTools
Restart ComfyUI after installing. One catch: the pack is built on the newer ComfyUI extension API, so it wants ComfyUI 0.18.0 or newer. If you install and the nodes don't show up in the menu, update ComfyUI first, then look at the nodes.
Common issues
The classic failure: you extract positive later and get a hard error that the key doesn't exist. That's because extracting a missing key raises "No such key in Dict" - deliberately, so you don't silently build prompts from nothing. Fix it by checking your spelling (and remembering cleanup_key normalizes spaces). And if you're staring at a dict wire with no idea what's inside, there's no built-in inspector node - that's normal. Extract a value and preview it, or pipe the dict into the author's recommended companion, StableLlama's Basic Data Handling pack, which exposes real dict methods as nodes.
Where the magic shows up: combine a few DictAddString nodes with the author's StringConstructor pack to assemble a full prompt from reusable chunks, or treat the dict as a settings bus that a whole workflow reads from. This one's a keeper.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| key | STRING | Key (name) of the item inserted into the dict. | |
| cleanup_key | BOOLEAN | true | Automatically remove leading/trailing spaces and extra newlines from the key. |
| value | STRING | The actual string to add into the Dict. | |
| cleanup_value | BOOLEAN | true | When enabled, each line in the value-string is individually stripped of any leading/trailing spaces. |
| dictopt | DICT | An (optional) Dictionary to work with. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| dict | DICT | — |