Text Find and Replace by Dictionary
Templated prompts with random fills
This one's more powerful than its dry name suggests. It takes a block of text with keys in it, looks each key up in a dictionary, and swaps it for a value - and here's the good part, per the README: when a key maps to multiple lines, it picks one at random based on the seed. So it's not just find-and-replace; it's a templating engine with built-in, reproducible randomness. Think A1111-style wildcards, but wired into your graph.
Why it's genuinely useful
Write one prompt template with placeholders - a subject key, a style key, a lighting key - and let this node fill them in from lists. Each run, every key gets a random pick from its options, so you get controlled variety without editing the prompt. Lock the seed and you reproduce an exact combination you liked. This is the pattern our prompt-engineering notes keep coming back to: the productive way to explore is a bank of interchangeable fragments you sample from, not one hand-tuned string. Text Find and Replace by Dictionary is a compact way to run that bank.
Compared to Text Random Line (which swaps a whole line), this does keyed substitution inside a larger text - multiple independent variables in one prompt, each pulling from its own list. That's the difference: one node picks a line, this one fills a template.
How it works
Three things go in: the text (your template, containing keys), a dictionary (keys mapped to one or more replacement lines), and a seed. The node replaces each key with a value from the dictionary; where a key has several possible lines, the seed decides which. The output is the finished text (a STRING) that you feed into CLIP Text Encode.
The dictionary comes from WAS's dictionary nodes - you can build one with Text Dictionary New / Update, or load it from a file with Load Text File (which can output a dictionary named after the file). That's the part beginners stumble on: the node doesn't guess your options, you have to supply the dictionary that defines each key's possible values.
Watch for these
- Keys must match exactly. If the key in your text doesn't match a dictionary key, it isn't replaced - you'll see the raw key left in the prompt. Check spelling and any delimiter format your dictionary uses.
- Seed controls the pick. Same seed, same choices. Wire the seed to something that changes each run for variety, or freeze it to reproduce a result.
- You need the dictionary wired up. No dictionary, nothing to replace. This node is the back half of a small setup, not a standalone.
Installing it
Part of WAS Node Suite. Install the pack via ComfyUI Manager (search was-node-suite-comfyui, install, restart) or clone it:
cd ComfyUI/custom_nodes
git clone https://github.com/WASasquatch/was-node-suite-comfyui
install requirements.txt, restart. No models - it's text processing.
Troubleshooting
If keys aren't being replaced, it's almost always a key-mismatch or a missing dictionary, not a bug. The pack-level failure is the other thing to know: WAS Node Suite has been unmaintained since December 2023, and the whole suite can report "Import Failed" after a ComfyUI update from a dependency clash (opencv, usually). Reinstall requirements.txt into the correct venv (activate it, or run install.bat) to bring it back.
Inputs (0)
No inputs
Outputs (0)
No outputs