MIM Prompt Get Random Templates
MIM Prompt Get Random Templates
- template
This is the lazy man's wildcard node, and honestly that's a compliment. You know how people build prompt variety by dropping fragments into wildcard .txt files and letting a wildcard processor shuffle them? This node does the shuffle without any of the file plumbing. You paste a list, it hands you back a random pick, one string out.
It pairs naturally with the rest of the ComfyUI Prompt Template pack (by DaniilVdovin) - the README's whole demo is feeding this into the template nodes' template_positive box so *obj gets filled with a randomly chosen subject. It also just feeds any STRING input in ComfyUI: a CLIP Text Encode, a prompt scheduler, whatever. Keep in mind the wider context from the wildcard discussion: randomizing subject/pose/setting per batch is the standard trick for getting variety out of a character library without retraining, and this is the cheapest possible version of it.
How it works
Mechanically it's dead simple, which is the point. It takes your multiline TemplatesParts, strips blank lines, dedupes them in order, then uses Python's random.sample to pull Count of them and joins the result with ", ".
Two behaviors worth knowing before you build a workflow on them. First, duplicates collapse - list cat five times and it's still one entry, so you can't weight your odds by repetition. Second, Count is clamped to the number of unique entries (the code does min(Count, len(unique))), so asking for 10 picks from a 3-line list quietly returns 3, not an error.
The inputs that matter
Only two, both optional:
- TemplatesParts - one candidate per line, e.g.
cyberpunk robot,gentle giant,tiny astronaut. The placeholder is literallyvalue\nvalue2\nvalue3. - Count - how many to pick, 1–1000, default 1.
And one output, template (STRING), the comma-joined picks.
Installing
Same story as the rest of the pack - it lives in custom_nodes, has zero dependencies (pure Python stdlib, no requirements file, no model downloads), so install is either the Manager route or:
cd ComfyUI/custom_nodes
git clone https://github.com/DaniilVdovin/ComfyUI-prompt-templating.git
Then restart ComfyUI. In Manager, search for "ComfyUI Prompt Template" (the pack title) or "prompt-templating".
Gotchas
The main one: this re-rolls on every execution. It uses the global random module, not your KSampler seed, so each queue run and even a preview recompute draws a fresh sample. Great for exploration, useless if you wanted a reproducible set - if you need the same picks twice, treat the output as a snapshot, not a value you can re-derive. And remember it returns one joined string: with Count = 1 you just get a single line, which is the common setup for plugging into a template node.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| TemplatesPartsopt | STRING | — | |
| Countopt | INT | 11–1000 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| template | STRING | — |