Nodes/comfyui-ux-combinatorial/Combinatorial Prompt Batch
ComfyUI Node

Combinatorial Prompt Batch

Stop getting 4 copies of the same image — batch 4 different prompts instead

By NevetCohen·Created 2 months ago·Updated 2 months ago· 0
Combinatorial Prompt Batch
    • prompts
    • effective_batch_size
    • combination_count
    positive_prompt
    batch_size1

    ComfyUI's batch size has a dirty secret: set it to 4 and you get four versions of the same prompt. If your goal is variety - "same character, different hair colors" or "one prompt, four outfits" - that's four nearly identical images you'll delete. CombinatorialPromptBatch is the fix: you type girl with {red|blue|green|black} hair and it hands ComfyUI four real prompts, one per slot. This is the old A1111 wildcard trick that most people who started after 2024 never learned, wrapped in a dependency-free node that lives in the Illustrious UX/prompt category.

    It's from the tiny comfyui-ux-combinatorial pack, which ships exactly this one node. No API keys, no model downloads, no Python deps - it's a string parser with a pretty front door.

    How it works

    The node runs a small recursive-descent parser over your prompt. When it hits a {, it collects the alternatives split by | and cartesian-joins them with whatever text came before - so {red|blue} {dress|shirt|coat} becomes six prompts, in order, duplicates preserved. Nested groups work too: {red|{blue|green}} ball gives you three.

    Two details the README glosses over but you'll care about:

    • Escaping is supported. \{, \}, \|, and \\ render as literal characters. Crucially, unrelated backslashes are passed through untouched, so prompt-weighting syntax doesn't get mangled.
    • The cap is 32 combinations. Hit it and the node throws a PromptSyntaxError instead of quietly truncating. That's a feature - you find out immediately rather than getting a mystery 32-image batch.

    One more behind-the-scenes thing worth knowing: the prompt widget is declared with dynamicPrompts: false. That tells the ComfyUI frontend not to run its own built-in dynamic-prompt expansion on that box, so the node receives your raw {a|b} text. It's taking over a job ComfyUI already sort of does - but doing it deterministically and giving you the expanded list to work with.

    Inputs and outputs that matter

    You'll touch two inputs, and really only one of them:

    • positive_prompt (multiline STRING) - where the {a|b} syntax goes. This is the whole node.
    • batch_size (INT, 1–4) - only used when your prompt has no dynamic groups. The moment there's an unescaped {} anywhere, it's ignored.

    The three outputs are where the node earns its keep:

    • prompts (STRING list) - wire this into your CLIP Text Encode's positive input and ComfyUI runs the graph once per prompt, so image #1 gets the red dress, #2 the blue, and so on.
    • effective_batch_size (INT) - 1 for a dynamic prompt, or the batch_size you set for a plain one. It's telling you what the batch actually is, since the two don't always agree.
    • combination_count (INT) - how many prompts got generated. Read this before you feed it a monster prompt and blow the cap.

    Installing it

    In ComfyUI Manager, Install via Git URL and paste https://github.com/NevetCohen/comfyui-ux-combinatorial, then restart. Or the manual route:

    cd ComfyUI/custom_nodes
    git clone https://github.com/NevetCohen/comfyui-ux-combinatorial.git
    

    Restart ComfyUI. That's it - there are no external packages to install, which is refreshing. If you're on RunDiffusion, the README has specific notes (you may need to flip allow_git_url_install = true in the Manager config if arbitrary Git URLs are blocked there).

    Where you'll trip over it

    The 32-combination cap is the #1 footgun. {a|b} {c|d} {e|f} {g|h} {i|j} is exactly 32 and fine; add a sixth group and it errors. Split the job into two passes or trim alternatives.

    The other classic confusion: batch_size does nothing once your prompt contains a group. Set it to 4, feed a dynamic prompt, and you get combination_count images, not 4. The outputs exist precisely so you can stop guessing - effective_batch_size and combination_count are the truth.

    One legit gotcha if you're mixing tools: this node expects raw {a|b} text. If you feed it output from a wildcard node that already expanded, or a prompt that came through a tool which ate the braces, you'll get stray braces or double expansion. Feed it the plain prompt and let it own the job.

    Is it going to change your life if you generate one image at a time? No. If you're building character reference sheets or testing tag combos on Illustrious-derived models, it's the cheapest variety machine in the graph.

    CategoryIllustrious UX/prompt

    Inputs (2)

    NameTypeDefaultDescription
    positive_promptSTRINGUse {red|blue}; every combination is emitted once.
    batch_sizeINT11–4Used only when the prompt has no dynamic groups.

    Outputs (3)

    NameTypeDescription
    promptsSTRING
    effective_batch_sizeINT
    combination_countINT