Random Find and Replace
Roll a random word into your prompt, one choice per line
- prompt
- random_choice
- seed
If you've ever used A1111's {red|blue|green} wildcard syntax or a dynamic-prompt setup, you know the trick: drop a placeholder in your prompt and let the machine roll a value for it each run. Random Find and Replace is that idea in one dead-simple ComfyUI node - a find-and-replace where the replacement is chosen randomly from a list.
How it works
You give it a prompt, a find string, and a choices list with one option per line. It seeds Python's random with your seed, picks one line, and does a plain string replace - every occurrence of find in the prompt gets swapped for that choice. That last detail matters: if find appears twice, both get the same choice in one run. To get independent rolls for two placeholders, run two of these nodes with different find strings (and consider different seeds).
Inputs: prompt (multiline), find (the placeholder text, default "String to Find & Replace"), choices (multiline, one option per line), and seed.
Outputs: prompt (the rewritten prompt - wire this into a CLIP Text Encode), random_choice (what got picked, useful for recording it in metadata or a filename), and seed (echoed back so you can chain or log it).
The inputs that matter
Honestly, just two. find and choices. Everything else is the obvious default. The one structural rule is the newline: choices are split on \n, so one option per line - and watch for trailing blank lines, because an empty line is a valid choice and will happily wipe your placeholder into nothing.
What it's for
Prompt generator setups, per the author's own README. Batch a bunch of seeds and get variety - roll a subject, a lighting word, a style tag. Combined with the seed output, your runs stay reproducible: same seed, same choice, same image. It's a small hammer, but it's exactly the hammer for "I want a different something every run without touching the prompt by hand."
Install
cd ComfyUI/custom_nodes
git clone https://github.com/braintacles/braintacles-comfyui-nodes
or search braintacles-nodes in ComfyUI Manager and restart. No Python dependencies, no model downloads - plain string handling, so nothing about ComfyUI updates can break it. One caveat: the pack is dormant since mid-2024, but this node is as stable as string manipulation gets.
Want more power than this? The ecosystem has bigger dynamic-prompt tools (wildcard packs with weighted options and nesting). This one is the 200-line version that does one job well and never nags you.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | — | |
| find | STRING | String to Find & Replace | — |
| choices | STRING | Choices | — |
| seed | INT | 00–18446744073709550000 | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| prompt | STRING | — |
| random_choice | STRING | — |
| seed | INT | — |