Dynamic Prompt (Combinatorial)
Every Combination, No RNG Roulette
- prompt
- all_prompts
- total_count
The Random node is great for variety, but sometimes you don't want a roll of the dice - you want every roll, systematically. That's Dynamic Prompt (Combinatorial): it takes a template like {a|b} {x|y} and expands it exhaustively into a x, a y, b x, b y. Where the sibling node picks one outcome, this one hands you the entire grid, and that grid is the point. If you've ever run a settings sweep and wished the same rigor applied to your prompts, this is the node.
The classic setup is a controlled experiment: three wildcard files of hair colors, outfits and scenes, expanded into every combination, rendered as a batch. People coming from A1111 know this as the "combinatorial" checkbox in Dynamic Prompts - this node is the ComfyUI-native version of exactly that, implemented in the same pack.
How it works
The template is parsed and every {...} group is enumerated rather than sampled. Wildcards behave differently here and it's worth internalizing: in Random mode a wildcard file contributes one random value, but in Combinatorial mode every value in the file becomes a branch. Three wildcards of twenty values each isn't sixty prompts - it's 8,000. That's why the node surfaces total_count before you commit.
The inputs and outputs that matter
Inputs are minimal: template (multiline STRING) and index (INT, default 0). But the outputs are where this node earns its keep:
- prompt - the single combination at
index. It wraps:prompt = results[index % len(results)], so a counter that overruns the list just loops back around instead of erroring. - all_prompts - the full list of expanded prompts. This is the one you actually want. It's a list-typed STRING output, so it plugs into a batch-capable prompt path and renders every variant in one go.
- total_count - how many combinations exist, so you can sanity-check the explosion before you hit Queue.
To drive all 8,000, feed all_prompts into a batch text node rather than fiddling with index - index is mainly useful when you want combination N of M and nothing else, like aligning with another sweep.
Installing it
Same pack as the others: search Dynamic Prompt Nodes in ComfyUI Manager, or:
cd ComfyUI/custom_nodes
git clone https://github.com/cesasol/dynamic_prompt_nodes
cd dynamic_prompt_nodes
pip install -e .
Pure Python, dependencies are just lark and pyyaml, no model files to fetch. Wildcards go in ComfyUI/custom_nodes/dynamic_prompt_nodes/wildcards/ or ComfyUI/models/wildcards/.
Where people get burned
Combinatorial explosion is the trap - it's genuinely easy to accidentally render 10,000+ images because one wildcard file you thought had 12 entries has 400. Check total_count first. Second, there's no seed here at all: the node seeds its RNG with 0 and ignores randomness, which is by design but surprises people who expected a "reroll" button. There isn't one, and there shouldn't be - exhaustive means exhaustive. And the prompt output at a fixed index will sit on the same combination forever unless something drives index, which trips up everyone who expected it to auto-advance. Use all_prompts for the sweep; save index for the surgical cases.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| template | STRING | — | |
| index | INT | 00–2147483647 | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| prompt | STRING | — |
| all_prompts | STRING | — |
| total_count | INT | — |