ComfyUI Node

Complex Prompt

The {a|b|c} prompt node that gives ComfyUI wildcards and $variables in one box

By ArtemKo7v·Created 4 months ago·Updated 4 months ago· 1
Complex Prompt
  • vars
  • string
prompt
seed0

If you came over from A1111 you remember the wildcard trick: {red|green|blue} in a prompt and suddenly one text box generates every color variation without you touching anything. ComfyUI's built-in text widgets won't do that for you, and most people end up hand-editing prompts or juggling a pile of "random prompt" API calls. Complex Prompt is the node that brings that A1111 magic into the graph - one node that expands {a|b|c} wildcards and swaps in $variables from the rest of this pack, with zero external APIs and no keys.

It's the flagship of the ComfyUI-Complex-Prompt pack, and honestly it's the only node in the pack you need. The others are there to feed it variables.

How it works

The mechanism is two passes, and the order matters. First it scans your prompt for $variable_name tokens and masks them into placeholder strings - that's so the wildcard engine doesn't mangle them. Then it runs the prompt through the dynamicprompts library (the same one A1111's dynamic prompts extension uses) with your seed, picks one variant per {a|b|c} group, and restores the masked tokens. Finally it substitutes every $var that has a matching key in the vars it was handed.

Two nice touches buried in there. If your prompt has no {a|b|c} syntax at all, it skips the generator entirely and just does variable substitution - so it's cheap to leave in a graph that mostly uses plain text. And unknown $variables are left literally in place ($person stays $person) instead of being deleted, which makes missing variables obvious instead of silently wrong.

The inputs that matter

Only three, and only two you'll actually set:

  • prompt - the multiline text box. Put your {red|green|blue} groups and $variable_name tokens here.
  • seed - passed to the wildcard generator. It's set to randomize after generation, so every queue run re-rolls your variants unless you pin it. That's the setting people forget when their "same seed, same image" plan falls apart.
  • vars (optional) - the ArtemKo7vComplexPromptVars object coming from the pack's Set Variable or Parse JSON nodes.

Output: string - the finished prompt, wired into CLIP Text Encode (positive prompt) or whatever your model expects. It's a plain STRING, so it slots in anywhere text goes.

The vars object deserves a mention: under the hood it's just a dict passed between the pack's nodes. Chain Set Variable → Set Variable → this node and each one layers on top of the previous.

Installing it

Same routine as every custom node, via ComfyUI Manager: search "ComfyUI Complex Prompt Nodes" and hit install. Or do it by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/ArtemKo7v/ComfyUI-Complex-Prompt
cd ComfyUI-Complex-Prompt
pip install -r requirements.txt

Then restart ComfyUI. Dependencies are light - dynamicprompts>=0.31.0 and simpleeval>=1.0.7 - no model downloads, no CUDA, nothing heavy.

Troubleshooting

The one error you're likely to hit is an ImportError about dynamicprompts - that means the node's requirements never got installed, which happens when you clone by hand instead of using Manager (Manager installs the pip deps for you). Fix it with pip install -r requirements.txt and restart.

Where people actually get burned: the seed. Because it randomizes after each generation, a batch you meant to reproduce will wander. Lock the seed when you want stable output, and remember the wildcard pick and the variable pick are seeded independently per node - two nodes, two seeds, two rolls. If a $var shows up as literal text, it's almost always because you didn't chain the vars output into this node, so it saw nothing to substitute. New pack, small community, but the README is unusually thorough for a node of this size - worth a skim before you go deep.

CategoryArtemKo7v

Inputs (3)

NameTypeDefaultDescription
promptSTRING
seedINT00–18446744073709550000
varsoptArtemKo7vComplexPromptVars

Outputs (1)

NameTypeDescription
stringSTRING