Nodes/ComfyUI Complex Prompt Nodes/Complex Prompt Combine Vars
ComfyUI Node

Complex Prompt Combine Vars

Last one in wins, and that's the point

By ArtemKo7v·Created 5 months ago·Updated a day ago· 1
Complex Prompt Combine Vars
  • vars_1
  • vars

Complex Prompt Combine Vars is the merge node of the ComfyUI Complex Prompt Nodes pack. It takes several ArtemKo7vComplexPromptVars bundles and squashes them into one, with later inputs silently overriding keys set by earlier ones. That's it. There's no configuration, no selector, no clever logic.

So why does it exist? Because the pack's Complex Prompt node replaces $variable_name tokens from a single vars object, and real workflows end up with more than one source of variables: a JSON block of presets, a Set Variable chain for the things you tweak by hand, a Set Variable By Choice picking a name off a gender variable. Each of those produces its own vars dict. The combiner is the funnel that gets them all onto one wire.

How the merge actually works

Chain-wise, you often don't need this node. Every Set Variable takes an optional vars input and hands back an updated copy, so a straight line of variables passes down one wire just fine. You reach for Combine Vars when your graph splits: two branches each contribute variables, and something downstream needs both.

The mechanism is dead simple, and it's worth knowing because the precedence is the whole feature. The node's Python declares exactly one input, vars_1. The extra sockets are minted client-side by a bundled frontend script (web/js/combine_vars.js) that adds vars_2, vars_3 and so on the moment you plug something into the last one, and tidies trailing empty sockets away again. The backend then copies vars_1 and calls update() on it for each remaining socket in numeric order. Later number wins, per key. Gaps are fine - unconnected sockets in the middle are just skipped.

Two consequences worth internalising. First, precedence follows the socket number, not where the node sits on your canvas - there's no dragging to reorder, you rewire. Second, this is a flat, whole-value override, not a deep merge: if two sources both set style, the later one replaces it outright. That's usually what you want. It's also how the pack expects you to review what a preset is doing - the merge is visible on screen, which is more than you can say for the context-bus pattern in comfyui-node-plumbing.md, where "which version of this value is inside the bundle" is genuinely hard to answer.

Inputs and output

You'll set nothing. vars_1 is required and it's an ArtemKo7vComplexPromptVars - wire in whichever group is your baseline. Everything after that is the dynamic vars_2, vars_3, … slots, which top out at 64 inputs you will never hit.

There's one output, vars, also typed ArtemKo7vComplexPromptVars. Feed it to the vars input on Complex Prompt (that's where $name tokens get substituted), or into a Set Variable to keep building, or into another Combine Vars if your graph has three branches.

A trick that falls out of the flat override: to blank a variable, override it with an empty value, and the pack ships Complex Prompt Empty String so you have something to drive that with. Base preset vars first, a Set Variable writing style = wired in second, and the preset's style is gone without editing the JSON.

Install

Easiest path is ComfyUI Manager: search "Complex Prompt" and install ComfyUI Complex Prompt Nodes, then restart. Manually:

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

That requirements file pulls dynamicprompts>=0.31.0 and simpleeval>=1.0.7. Neither is used by this node - dynamicprompts expands {red|green|blue} variants, simpleeval evaluates conditions in Set Variable - but they ship as one pack and both are imported lazily, so a missing one won't stop ComfyUI booting - it errors the moment you run a node that needs it.

Where people trip up

The extra sockets are drawn by the pack's frontend extension, so if you cloned the repo while ComfyUI was running, don't be surprised when the node shows one lonely input. Restart ComfyUI, then hard-refresh the browser tab (Ctrl-Shift-R) - a cached frontend is the usual cause.

Merging is silent by design. If a variable ends up with the wrong value, nothing errors; the last wire simply won. Check the final prompt string from Complex Prompt, where an unknown $variable_name stays literally in the text instead of vanishing - that's your signal that a name never got set, or got spelled differently. Same family of confusion as the wildcard YAML threads: unimplemented syntax passes through as plain text rather than complaining.

And because the backend's declared schema is only vars_1, workflows opened somewhere that doesn't run the pack's frontend - a headless API prompt, say - will show just the one input. The pack is young (version 0.1.3, September 2026, zero Reddit footprint so far), so when something looks off, the source in nodes.py is a couple of dozen readable lines rather than a forum post.

CategoryArtemKo7v

Inputs (1)

NameTypeDefaultDescription
vars_1ArtemKo7vComplexPromptVars

Outputs (1)

NameTypeDescription
varsArtemKo7vComplexPromptVars