Tired of rewriting the same prompt over and over just to try a different hair colour, outfit, place or lighting? Wildcards fix that.
You write one prompt template such as a __animal__ in a {forest|desert|city} at __time__, and ComfyUI picks something different every run, so a batch of 50 images gives you 50 genuinely different ideas.
This guide covers every way to use wildcards in ComfyUI in 2026: the built-in {a|b|c} syntax that needs no custom nodes, the Impact Pack wildcard nodes, and the Dynamic Prompts nodes.
It shows where the .txt files go, the full syntax (weights, multi-select, nested options, LoRA tags), how seeds work, how to save the final prompt in your images, and how to fix wildcards that don’t change.
- No custom nodes: type
{red|blue|green}in a CLIP Text Encode box. ComfyUI picks one option each time you queue. - Wildcard files (
__name__): install Impact Pack or Dynamic Prompts. - Impact Pack files:
custom_nodes/ComfyUI-Impact-Pack/custom_wildcards/. Use the ImpactWildcardProcessor or ImpactWildcardEncode node. - Dynamic Prompts files:
ComfyUI/wildcards/. Use the Random Prompts or Combinatorial Prompts node. - One line per option in each .txt file.
wildcards/hair.txtbecomes__hair__. - Same image every time? Set the seed’s “control after generate” to randomize.
New to ComfyUI? Start with my ComfyUI guide, which covers install, nodes and workflows in one place.
What Wildcards Are
A wildcard is a placeholder in your prompt that gets swapped for a random value when the workflow runs. There are two kinds:
- Inline choices:
{sunrise|sunset|night}. The options are right there in the prompt. - File wildcards:
__weather__. The options live in a text file calledweather.txt, one per line, so you can keep long lists (hundreds of outfits, art styles or locations) out of your prompt.
This idea came from the Dynamic Prompts extension for Automatic1111 and is now standard in ComfyUI too. It’s the fastest way to explore a model, build a varied dataset for LoRA training, or batch-generate variations overnight.
Built-in Random Choices (No Custom Nodes)
ComfyUI’s own interface already understands the curly-brace format. Prompt boxes on nodes like CLIP Text Encode are flagged for dynamic prompts in ComfyUI’s source, and the frontend replaces {a|b} with a random choice each time you press Queue.
Try it: in your positive prompt, type:
portrait of a woman with {red|black|blonde|silver} hair, {studio lighting|golden hour|neon city lights}
Then set the batch count to 8 (in the Queue/Run button’s options) and run. Each queued job gets a different combination.
What built-in support can’t do:
- Read options from files (
__hair__won’t work). - Weights, multi-select or combinatorial “every combination” runs.
- Save the chosen text separately. The resolved prompt is what gets stored with the image, which is often what you want anyway.
For anything beyond simple inline choices, install one of the two packs below.
Impact Pack vs Dynamic Prompts
| Impact Pack | Dynamic Prompts | |
|---|---|---|
| Repo | ltdrdata/ComfyUI-Impact-Pack | adieyal/comfyui-dynamicprompts |
| Main nodes | ImpactWildcardProcessor, ImpactWildcardEncode | Random Prompts, Combinatorial Prompts, Jinja2 Templates, Magic Prompt |
| Wildcard folder | ComfyUI-Impact-Pack/custom_wildcards/ |
ComfyUI/wildcards/ (or the extension’s own folder) |
| File types | .txt and .yaml | .txt, .json and .yaml |
| LoRA tags in prompts | Yes, <lora:name:weight> (Encode node) |
No |
| Every-combination mode | No | Yes (Combinatorial Prompts) |
| Shows the resolved prompt | Yes, in the node’s “Populated Prompt” box | Via a Preview Any node, or saved to metadata |
| Extra benefits | Face Detailer, detection and more | Lightweight, A1111-compatible syntax |
Which should you pick? If you already use Impact Pack for the Face Detailer, use its wildcard nodes. They also handle random LoRAs. If you want a small, single-purpose pack or need to step through every combination, use Dynamic Prompts.
Both install from ComfyUI Manager → Custom Nodes Manager. Search for “Impact Pack” or “dynamicprompts”, install, then restart ComfyUI. If you don’t have the Manager yet, see how to install ComfyUI Manager.
Create Wildcard Files
A wildcard file is a plain text file with one option per line. For example, hair.txt:
short red bob
long wavy black hair
silver pixie cut
braided blonde hair
curly auburn hair
Rules that apply to both packs:
- The file name (without .txt) is the wildcard name:
hair.txtbecomes__hair__, with two underscores on each side. - Subfolders become path prefixes:
wildcards/clothing/jackets.txtbecomes__clothing/jackets__. - Lines can themselves contain other wildcards or
{a|b}choices, so you can nest them. - Save files as UTF-8. Notepad, VS Code or Notepad++ are all fine.
You don’t have to write everything yourself. Dynamic Prompts links to ready-made collections, and there are many community packs on GitHub and Civitai. Check what’s inside before you use a pack, because some contain content you won’t want on a work machine.
Method 1: Impact Pack Wildcards
Where the files go
Impact Pack creates two folders inside ComfyUI/custom_nodes/ComfyUI-Impact-Pack/: wildcards and custom_wildcards. Its docs recommend putting your files in custom_wildcards, so updates to the pack don’t conflict with them. You can point custom_wildcards at another folder in impact-pack.ini, which the pack creates on first start.
ImpactWildcardProcessor
- Add ImpactWildcardProcessor (double-click the canvas and search “wildcard”).
- Type your template in the top box (Wildcard Prompt), for example:
photo of a __animal__ wearing a {tiny hat|scarf|backpack}, __lighting__. - Leave the mode on Populate.
- On your CLIP Text Encode node, right-click and convert the text widget to an input (in new frontends, just drag the processor’s STRING output onto the text box). Connect the processor’s output to it.
- Queue. The bottom box (Populated Prompt) shows the prompt that was actually used.
Impact’s docs explain the two modes. Populate fills the bottom box from the template on each queue and makes it read-only. Fixed ignores the template and lets you edit the bottom box by hand. Switch to Fixed when you find a result you want to keep and tweak.
The Select to add Wildcard dropdown on the node lists every wildcard file it found. Pick one to insert its __name__ into the prompt.
ImpactWildcardEncode
This node does the same thing, but also takes a model and clip, applies any LoRA tags in the prompt, and outputs ready-made conditioning. Use it in place of CLIP Text Encode when you want random LoRAs (see below).
Seeds in Impact Pack
The processor has its own seed. Impact’s docs say the wildcard is resolved in the browser before the workflow runs, so if you convert the seed to an input, only ImpactInt or Seed (rgthree) nodes can drive it.
Method 2: Dynamic Prompts
Where the files go
Put wildcard files in ComfyUI/wildcards/ (create it if needed) or in the extension’s own wildcards folder. You can add more folders under a wildcards key in extra_model_paths.yaml. Edits are picked up on the next run without restarting.
Random Prompts
- Add Random Prompts (category: Dynamic Prompts).
- Type your template, for example:
a {red|green|blue} __vehicle__ parked by the {sea|mountains}. - Drag its STRING output onto CLIP Text Encode’s text box.
- Set the seed’s control after generate to randomize, or set
autorefreshto Yes. - Add a Preview Any node to the STRING output if you want to see the prompt it made.
The README notes that the same template, seed and wildcard files always produce the same prompt. That’s handy for reproducing a result.
Combinatorial Prompts (every combination)
Instead of random picks, this node walks through every combination, one per run. Its index starts on increment, so a {red|green|blue} ball gives a red ball, then a green ball, then a blue ball, then wraps around.
The combinations output tells you the exact total, so you can set your batch count to match. This is ideal for comparison grids, for example every sampler with every style.
Jinja2 and Magic Prompt
Jinja2 Templates lets power users write loops and logic. Magic Prompt expands short prompts with a small language model (MagicPrompt-Stable-Diffusion, about 500 MB, downloaded on first use). For LLM-written prompts with a modern model, see how to generate text with an LLM in ComfyUI.
Syntax Cheat Sheet
This is the Impact Pack syntax, from its official tutorial. Dynamic Prompts uses the same core syntax ({a|b}, __file__, N:: weights, $$ multi-select). Check its syntax guide for the extras it adds.
| You write | What happens |
|---|---|
{red|green|blue} |
Picks one option |
{blue apple|red {cherry|berry}} |
Nested: can give “red cherry” or “red berry” |
__hair__ |
Random line from hair.txt (case-insensitive) |
__clothing/jackets__ |
Random line from a file in a subfolder |
__clothing/*__ |
Random line from all files in that folder |
{5::red|4::green|7::blue|black} |
Weighted pick: higher numbers come up more often |
{2$$red|green|blue} |
Picks exactly 2 options |
{1-3$$red|green|blue} |
Picks between 1 and 3 options |
{2$$ and $$red|green|blue} |
Picks 2, joined with ” and “ |
{2$$, $$5#__flower__} |
Repeats the wildcard 5 times as options, then picks 2 |
# comment |
A line starting with # is removed |
Note the weight format. Impact changed it from {5:red|...} to {5::red|...} with a double colon, so update old prompts that use a single colon.
Random LoRAs With Wildcards
With ImpactWildcardEncode (and Impact’s Detailer wildcard), you can put LoRA tags right in the prompt or in a wildcard file:
<lora:name:model_weight:clip_weight>
If you leave out clip_weight, it uses the model weight. So a styles.txt wildcard could hold:
watercolor painting <lora:watercolor_xl:0.8>
1980s anime still <lora:retro_anime:0.7>
claymation figure <lora:clay_style:0.9>
Then __styles__ in your prompt picks a style and loads the matching LoRA on each run. The LoRA files must be in your models/loras folder. If LoRAs don’t seem to apply, see my LoRA not working fix.
Impact also supports BREAK in the Encode node, which encodes each part separately and joins them with Conditioning (Concat).
Save the Final Prompt in Your Images
ComfyUI saves the workflow inside each PNG. What ends up there depends on the method:
- Built-in
{a|b}: the resolved text is sent to the server, so the saved workflow has the chosen words. - Impact Pack: its docs say that when the image is saved, the node is stored in Fixed mode with the populated text already filled in. Dragging the PNG back in reproduces the exact prompt.
- Dynamic Prompts: by default, the metadata stores the template, not the result. Set
save_to_metadatato Yes and Save Image adds adynamicpromptsentry with the generated prompt. (The node then re-runs on every queue instead of being cached.)
To keep and share those workflows, see how to save and share ComfyUI workflows.
Useful Wildcard Ideas
- Quality presets: save your usual quality tags as
ppos.txt, then write__ppos__, beautiful mountain lake. Impact’s docs use this exact trick. - Camera and lens:
{35mm|50mm|85mm} lens, {f/1.8|f/4|f/8}for photo realism tests. - Lighting: a
lighting.txtfile with 30 lighting setups. - Locations and times:
__location__ at {dawn|noon|dusk|night}. - Model testing: combine Combinatorial Prompts with a fixed seed to compare styles fairly.
- Dataset building: vary pose, clothing and background around a fixed character description.
Troubleshooting
The prompt is the same on every run
The seed is fixed. Set “control after generate” to randomize on the wildcard node’s seed (or set Dynamic Prompts’ autorefresh to Yes). Also remember that ComfyUI caches nodes whose inputs haven’t changed.
__name__ appears literally in the image
The file wasn’t found. Check the folder for your pack (custom_wildcards for Impact, ComfyUI/wildcards for Dynamic Prompts), the spelling, and that the file really ends in .txt and not .txt.txt. Also check you used two underscores on each side. Built-in ComfyUI doesn’t read files at all, so you need one of the packs.
Impact Pack doesn’t list my new file
Restart ComfyUI so the pack rescans its folders. Very large collections (50 MB or more) switch to on-demand loading, which shows “On-Demand” in the selector instead of “Full Cache”.
Weights are ignored
Use the double-colon format {5::red|2::blue}.
The node won’t accept a seed input
For Impact wildcards, only ImpactInt or Seed (rgthree) work as seed inputs, because the prompt is resolved before execution.
Custom node import failed
See ComfyUI import failed and missing nodes fix.
FAQ
Does ComfyUI support wildcards without custom nodes?
It supports inline {a|b|c} choices in prompt boxes out of the box. File wildcards like __hair__ need Impact Pack or Dynamic Prompts.
Can I use my A1111 wildcard files?
Yes. They’re the same plain .txt format. Copy them into your pack’s wildcard folder, or add the A1111 folder under a wildcards key in extra_model_paths.yaml for Dynamic Prompts.
How do I randomise the negative prompt too?
Add a second wildcard node and connect it to the negative CLIP Text Encode.
Can wildcards include other wildcards?
Yes. A line in one file can contain __another__ or {a|b}, and both packs resolve them recursively.
Do wildcards work with Flux, SDXL and Z-Image?
Yes. Wildcards only change the text before it’s encoded, so they work with any model that takes a text prompt.
How do I see which prompt made an image?
With Impact Pack, look at the Populated Prompt box or drag the PNG back in. With Dynamic Prompts, enable save_to_metadata or add a Preview Any node.
Sources
- Impact Pack tutorial: ImpactWildcardProcessor / ImpactWildcardEncode (syntax, modes, folders, LoRA tags, seed limits, on-demand loading)
- comfyui-dynamicprompts README (nodes, folders, seeds, save_to_metadata, Magic Prompt)
- Dynamic Prompts syntax guide
- ComfyUI source: nodes.py (dynamicPrompts flag on CLIP Text Encode)
- ComfyUI frontend: dynamicPrompts extension ({a|b} chosen when queued)



