Silver String Replacer
Swap a Word in Your Prompt for a Random Pick — Your Mini Wildcard Engine
- STRING
If you've seen wildcard packs that do {blonde|brunette|redhead} in prompts, this is the same idea stripped to its skeleton: you define a search term and a list of replacements, and each run swaps in a random one. Write dog:cat:puppy:wolf as a rule, and every "dog" in your prompt becomes "cat", "puppy", or "wolf" - you don't know which until the run happens. It's prompt variation with zero dependencies and no syntax to learn, and it's perfect for batch-testing a handful of variations of one prompt.
How it works
The replacement_pattern box holds your rules, one per line, in this format:
search_term:replacement_1:replacement_2:replacement_3
The part before the first colon is what gets searched for; everything after the colons is the pool of possible replacements. Each rule is applied independently, and when a match happens the node picks one replacement at random. The pattern comes from the README and the code follows it exactly.
Two details worth knowing. First, replacements are applied with a plain str.replace, so a search term replaces all occurrences in the text - and all of them get the same random pick. "dog dog" with dog:cat:puppy becomes "cat cat" or "puppy puppy", not one of each. Second, lines without a colon (or with no usable replacement) are silently skipped, so a typo just means that rule does nothing.
Inputs and output
- text - the string to transform. It's marked
forceInput, so you'll wire this from a prompt node, a text file loader, or whatever's upstream rather than typing directly. - replacement_pattern - the rules, multiline.
- STRING - the transformed text. Wire it into your positive prompt.
Gotchas
Colons are the separator and there's no escaping, so a search term containing a colon simply can't be expressed - avoid matching things like "time: 2am". Replacement text with colons has the same problem. Order matters if two rules overlap (e.g. red and red:blue - whichever rule comes first in the file wins its replacement first, and the second rule then searches the already-modified text). There's no case-insensitivity option, so Dog won't match dog. And if the pattern box is empty, the node returns the input unchanged - useful as a bypass, easy to forget when you think you've enabled variation.
The honest comparison: if you're already running a wildcard pack, you probably don't need this. But if you want one tiny, predictable substitution node and none of your packs include one, this fits in a single line of your workflow without dragging in a dependency.
Install
ComfyUI Manager → search "ComfyUI Silver Nodes", or:
cd ComfyUI/custom_nodes
git clone https://github.com/SilverAndJade/comfyui-silver-nodes
Restart after cloning. Purely stock-ComfyUI dependencies.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| replacement_pattern | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |