Nodes/DynamicPrompts Custom Nodes/Combinatorial Prompts
ComfyUI Node

Combinatorial Prompts

Combinatorial Prompts (DPCombinatorialGenerator)

By adieyal·Created 3 years ago·Updated 2 years ago· 430
Combinatorial Prompts
    • STRING
    text
    seed0
    autorefreshNo

    Combinatorial Prompts is the "give me every combination" sibling of Random Prompts. Same {blue|red|green} syntax, same wildcard files - but instead of rolling the dice and picking one, it walks through all of them, one per run, in order. If you want to see how your prompt behaves across a whole grid of options rather than a random handful, this is the node.

    Think of it as the difference between shuffling a deck and dealing off the top. Random Prompts shuffles every time. Combinatorial deals the cards in sequence: card one, card two, card three, and when it runs out, it starts the deck over. That ordering is the entire point - you get systematic coverage, not luck.

    How it works

    Take A {red|green|blue} ball. Random Prompts might give you "green" three times in a row. Combinatorial gives you exactly this sequence across successive runs, straight from the pack's own docs:

    • A red ball
    • A green ball
    • A blue ball
    • A red ball (and it cycles)

    Multiple variants multiply out. A {red|blue} {big|small} ball has 2 × 2 = 4 combinations, and the node steps through all four before repeating. Wildcards (__color__ file lookups) fold into the same expansion. So it's the tool for a proper A/B/C/D sweep - swap one variable, hold everything else, and compare like-for-like. Prompt matrices, essentially, done inside the graph.

    The catch to keep in your head: because ComfyUI is stateless, "the next combination" is tracked per run. You advance the sequence by running the graph repeatedly (a batch, or repeated queues), not by twiddling a count widget. Queue it 4 times for the ball example and you've covered the set.

    Inputs and outputs

    • text - your prompt with variants/wildcards in it. Multiline.
    • seed - present here as it is on the random node; it factors into how the generator initializes.
    • autorefresh - Yes/No, forces regeneration each run rather than serving a cached result.

    Output is one STRING, which you drop into a CLIP Text Encode node - positive or negative. Downstream of that, your workflow is completely normal; only the prompt text is being cycled.

    Installing it

    It ships in the same pack as everything else here, so if you've already got Random Prompts you've got this. Otherwise, ComfyUI Manager → search dynamicprompts → install → restart. Or manually:

    git clone https://github.com/adieyal/comfyui-dynamicprompts custom_nodes/comfyui-dynamicprompts
    python -m pip install -r custom_nodes/comfyui-dynamicprompts/requirements.txt
    python custom_nodes/comfyui-dynamicprompts/install.py
    mkdir custom_nodes/comfyui-dynamicprompts/wildcards
    

    Restart after. Wildcard files (.txt/.json/.yaml) live in that wildcards folder; the node reads __name__ against them.

    Where people get burned

    Combinatorial explosion is real. Three variants with five options each is 5 × 5 × 5 = 125 combinations, and a wildcard file pointing at a 200-line list blows that up fast. It won't crash - it'll just take a very long time to cycle through everything, and you'll wonder why you keep seeing "new" prompts hundreds of runs in. Count your options before you batch. If the full grid is huge and you only want a sampling, that's exactly when you want Random Prompts instead.

    Expecting one queue to give you the whole set. It doesn't - each run yields the next combination. Set your batch size (or repeat count) to the number of combinations you actually want to sweep, and let it step through.

    And the usual pack habit: the rolled prompt lands in the console. Wire the output into the pack's OutputString node if you want to read each combination on the canvas as it steps through - handy for confirming the sweep is actually covering what you think it is.

    CategoryDynamic Prompts

    Inputs (3)

    NameTypeDefaultDescription
    textSTRING
    seedINT0
    autorefreshCOMBONo2 options: Yes, No

    Outputs (1)

    NameTypeDescription
    STRINGSTRING