AB Wildcard
AB Wildcard in ComfyUI
- text
You know that trick where you batch 32 images and get the same character across different settings without training anything? That's the bracket hack - {blonde|brunette|redhead} inside one prompt - and AB Wildcard is the grown-up version of it. It's a single text-processing node that expands __tokens__, {choices}, variables, and even little [if ...] conditionals into a full prompt before it ever reaches CLIP. No API, no model downloads, no key. Just a string in, a richer string out.
The name undersells it. AB Wildcard is a heavily modified fork of Comfy-UmiAI that stripped out the LLM integration, LoRA handling, resolution control and API calls, and kept only the text engine - then added weighted selection, deep nesting and custom separators. That's a feature, not a cut: it means it's pure, fast, and deterministic.
How it works
The mechanism is simple and worth understanding because it explains every quirk. On each run the node seeds Python's random with its seed input, so the same seed produces the same picks every time. It then loops over your text up to 50 times, resolving variables, __wildcard__ references, {choices} and conditionals until nothing changes - which is what makes "deep nesting" like {a|{b|{c|d}}} work. It also strips comments: any line starting with // or # is ignored, and inline // cuts everything after it.
Where people get burned: that comment stripper doesn't know about URLs. If your prompt references a site with // in it, everything after the slashes silently vanishes. Keep URLs out, or don't use inline // comments in the same prompt. The other classic is forgetting the seed. Wire the KSampler's seed (or a Seed node) into AB Wildcard's seed input - otherwise every queue item with the same text gives the same variations and you'll swear it's broken.
The inputs that matter
There are only two, both in required:
- text - your prompt with wildcard tokens, multiline. This is where all the syntax lives:
__colors__pulls a random line fromwildcards/colors.txt,__2$$colors__picks two,{5::red|3::blue|green}does weighted choice,$color = {red|blue}defines a variable you can reuse as$color.upperor$color.title, and[if $color=red : fire theme | water theme]does conditional logic. - seed - the integer that makes all of it reproducible. Default 0.
The one output is text, a STRING. That goes straight into a CLIP Text Encode node. It can also feed any other text input - some people chain a second AB Wildcard pass to build more elaborate prompts. Nothing else connects to it.
Installing it
Easiest route is ComfyUI Manager: search "ComfyUI_AB_Wildcard" (it's published as "AB Wildcard Text Processor"), install, restart. Manual way:
cd ComfyUI/custom_nodes/
git clone https://github.com/a-und-b/ComfyUI_AB_Wildcard.git
pip install -r ComfyUI_AB_Wildcard/requirements.txt
Then restart ComfyUI. The dependency story is one line: pyyaml. That's it. No torch extras, no model files to fetch - the pack ships example wildcard files in its own wildcards/ folder, and it also reads ComfyUI/wildcards and ComfyUI/models/wildcards if you keep your own token banks there. It's about as lightweight as a custom node gets.
Gotchas and day-one workflow
Drop your own .txt (one entry per line) and .yaml card files into a wildcards folder, then click Refresh Wildcards - new files aren't picked up until you do. Autocomplete helps: type __ or <[ in the text box and a dropdown of your wildcards and tags appears (works in both the classic and Vue 2.0 renderers). <[tag]> aggregates YAML cards by tag, __Card Name__ pulls a specific card.
For batch variation, use the Queue Batch feature rather than latent batch size - each queued item gets its own seed and therefore its own prompt. Same seed, same image subject, every time. That's the whole point.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| seed | INT | 00–18446744073709550000 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |