Random Prompt
Random prompts, wildcards, and a seed that actually works
- STRING
Random Prompt is the node from the Qaz Tools pack that most people land on first, and it's the standalone version of a feature most workflows get from Impact Pack or the Dynamic Prompts extension: {red|blue|green} variants plus __wildcards__ pulled from a folder of .txt files. The difference is that this one does it with a seed you control, and it does it all itself - no add-on, no dependencies, no API call.
Reach for it when you want a workflow that varies one prompt slot (style, subject, lighting, an artist name) run after run without editing text. The classic setup: fix the KSampler seed, randomize part of the prompt, and compare a handful of outputs. Prompt engineering talk keeps circling back to "vary the prompt, hold everything else constant" as the cheapest way to explore what a model can do - this node is that idea with a queue button.
How it works
The node runs a small recursive-descent parser over the text field. {a|b} picks one option at random; __name__ loads values from a wildcard file and picks one; both nest and mix freely.
{red|blue|green}- one color, chosen randomly{cat|{big|small} dog}- nested variants work fine__colors__- one line fromComfyUI/wildcards/colors.txt, picked at randoma {__color__|red} car- wildcard mixed with literals
Wildcard values get re-parsed, so a line in colors.txt can itself contain {deep|crimson} red and it just works. The text widget is also explicitly marked dynamicPrompts: False, so ComfyUI's own frontend prompt expansion leaves the string alone and this parser is the only thing that touches it. Need literal braces or pipes? Escape them: \{ \} \| \\.
The inputs that matter
Only three, and really two of them:
text- your template. Multiline, this is where the syntax lives.seed-0(default) means no reseeding: every queue gives a fresh prompt. Set it above0and the same seed reproduces the same prompt every run, which is what you want once you've found a winner and need to debug the rest of the graph against a fixed input.autorefresh- Yes/No. Honest note: it's in the schema, but the node re-executes on every run regardless (IS_CHANGEDreturnsNaNunconditionally). In practice the setting is vestigial - seed0always gives a new prompt, a fixed seed always gives the same one.
The output is a single STRING. Wire it into a CLIP Text Encode (positive), or into the pack's QazOutput node to see exactly what it generated this run.
Installing Qaz Tools
Same install for every node in this pack. Qaz Tools is a small personal toolkit from qazwsxedc121 - six text-utility nodes, no model downloads, no requirements.txt, nothing heavy to pull in. Pick one, then restart ComfyUI.
cd ComfyUI/custom_nodes
git clone https://github.com/qazwsxedc121/comfyui-qaz-tools
Or in ComfyUI Manager, search "Qaz Tools" or paste the repo URL under Install via Git URL.
Where people get burned
- A wildcard that doesn't resolve doesn't error - you get the literal
__name__sitting in your prompt. Check the file lives inComfyUI/wildcards/(notcustom_nodes/), one value per line; blank lines and lines starting with#are ignored. - An unclosed
{or__throws a parse error and the run fails. The message names the character position, which narrows it down fast.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| seed | INT | 0 | — |
| autorefresh | COMBO | No | 2 options: Yes, No |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |