Template Processor
Random prompt slots, without installing a wildcard pack
- vars
- result
Template Processor is the node this whole pack is built around. It takes a template with {placeholders} in it, looks up each placeholder in a list of named variables, picks a random value for each, and hands you a filled-in prompt string. If that sounds like wildcards, it is - but it's the structured kind. Instead of writing {brown|blonde|black} hair inline, you define the options once (name + list of values), then reuse them across as many templates as you want.
That structure is the point. Random alternatives are how people batch variety - same subject in different weather, lighting, moods - without hand-writing thirty prompts. Inline bracket syntax works for a single pass; named variables you can reuse and reason about work better when you're building a library.
How it works
For each entry in the vars list it reads a name and an items list, picks one item with random.choice, and then replaces every {name} in the template with that pick. The code is five lines and does exactly what it says:
var_map[name] = random.choice(items)
template = template.replace(f"{{{key}}}", val)
So an Item List node named adjective with sunny / cloudy / rainy, plus the template Today is a {adjective} day., gives you "Today is a rainy day." on any given run.
Inputs and output
template- the template STRING with{bracketed}slots. Comes naturally from this pack's Template Input node, but any string works.vars- a LIST input. This is the output of the pack's Item List node; one Item List defines one named slot. The Processor takes a single LIST, so multiple independent slots need their list outputs merged upstream first.trigger- a FLOAT, default0, and the thing beginners miss. Look at the source and it's literally labeled "dummy input." Its job is forcing re-execution.
Why the trigger exists
ComfyUI only re-runs a node when one of its inputs changes. That means if you run the queue again with everything untouched, the Processor won't re-roll - you'll get the same "rainy day" every time, because the node didn't execute. Change trigger (or any other input) and it executes again, re-picking random values. This is the classic ComfyUI "force a fresh pass" trick, and here it's the difference between the node doing its job and silently doing nothing. If your variations never vary, this is the first thing to check.
The output result is a plain STRING - wire it into a CLIP Text Encode. It's model-agnostic: it doesn't care whether your encoder wants Danbooru tags or natural-language sentences, because by the time it sees the text, the placeholders are already filled.
Installing it
No dependencies, no model downloads - the pack is pure Python stdlib. ComfyUI Manager, search i-zygion-util-nodes, or:
cd ComfyUI/custom_nodes
git clone https://github.com/zygion/comfyui-zygion-util-nodes
Restart ComfyUI; it lives under Zygion Custom Nodes.
Troubleshooting
- Braces in the finished prompt.
{adjective}still in the output means the Processor didn't replace it - almost always a name mismatch between the placeholder and the Item List'sname, or an emptyitemslist that got skipped. Names must match exactly. - Output never changes. See above - bump the
trigger. - It re-rolls when you don't want it to. Every execution re-randomizes. When a run gives you a result you like, copy the filled string somewhere, or accept that re-running the queue can change it.
That's the whole node. For random prompt variation without a wildcard pack, it does the job cleanly - just remember the trigger is the button.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| template | STRING | — | |
| vars | LIST | — | |
| trigger | FLOAT | 0.00 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| result | STRING | — |