🏷️ Text Random Replacer Chain
Random tag swap plus a fixed base prompt, in one node
- completed_prompt
"🏷️ Text Random Replacer Chain" is the pack's "do the random swap and bolt it onto something" node. It takes an input_chain - a base prompt you want to keep fixed - plus a text block with a #TAG in it, runs the same weighted replacement as the other replacers, and returns the chain with the randomized block appended. So instead of wiring a replacer into a separate concatenator and fighting over separators, one node gives you: [fixed base prompt] [randomly chosen variation].
How it works
Mechanically it's the replacer engine with a string append on the end. The text field is processed exactly like Text Random Replacer (MultiLine): your #TAG gets swapped for one weighted line from replacement_options, any {a|b} brackets in the result get expanded, and the finished block is joined onto input_chain. The code literally concatenates input_chain + " " + processed, so the separator between the two halves is exactly one space.
That space is the thing to internalize. If your chain ends in cinematic lighting and your randomized block starts with a cyberpunk hacker, you get "cinematic lighting a cyberpunk hacker" - no comma. For tag-style prompts you'll almost always want to end the chain with a comma: cinematic lighting, and then the appended block reads naturally. For sentence-style prompts a space is exactly right. There's no smart punctuation handling here, so the separator lives and dies with what you type.
The inputs that matter
- input_chain - the fixed base prompt, single line, prepended to the result.
- text - the template containing
#TAG, multi-line friendly. - target_tag - default
#TAG; the placeholder the randomizer replaces. - replacement_options - candidates, one per line,
::weightto bias. - seed - pins the pick.
Output: completed_prompt (STRING) - chain plus randomized block, ready for a CLIP Text Encode.
Installing it
Standard pack install, and this pack is the easiest kind: no requirements.txt, no model downloads, no GPU footprint, pure Python stdlib. The README is a "TODO." stub, but the code is short, readable, and self-contained.
ComfyUI Manager → Custom Nodes Manager → search "TextRandomizer" → Install → Restart
or cd ComfyUI/custom_nodes && git clone https://github.com/fls-eugene/ComfyUI_TextRandomizer, then restart. No pip step.
Where it earns its place
The chain pattern is the standard way people structure randomized prompts: a locked style block (camera, lighting, quality) with a swappable subject block on the end. This node just merges the two steps into one, which keeps your graph smaller than replacer-plus-concatenator. The trade-off is the rigid space separator - if your two halves need a comma, a comma goes at the end of the chain. And the same silent-failure rule as its siblings applies: no #TAG in text, no randomization, no error. Check your placeholder spelling once and this node becomes the one you reach for on every variety batch.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| input_chain | STRING | — | |
| text | STRING | — | |
| target_tag | STRING | #TAG | — |
| replacement_options | STRING | — | |
| seed | INT | 00–18446744073709550000 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| completed_prompt | STRING | — |