Nodes/ComfyUI-SBTools/Variable Prompt (SBTools)
ComfyUI Node

Variable Prompt (SBTools)

The heart of SBTools' variable system — one variable node that cycles, randomizes, or branches

By Amatsukast·Created 5 months ago·Updated 21 days ago· 2
Variable Prompt (SBTools)
  • var_list
  • VAR_LIST
tag_name
valuesvalue1 value2 value3
randomizefalse
prefix
suffix
output_to_prompttrue

Prompt variety is the eternal ComfyUI chore. The classic move is wildcard syntax - {this|that|the other} inside a prompt, A1111-style - which works but only gives you one random draw per run and no real control over which combination you land on. Variable Prompt is this pack's answer: a single node that defines one variable with a list of values, and lets you cycle through them sequentially, pick randomly, or even change the available values based on what another variable chose.

This is the node the whole SBTools variable system is built around. One Variable Prompt per slot (GENDER, AGE, CLOTHING…), chain them together, and a Variable Builder at the end assembles the actual prompt text. Think of it as a structured, deterministic replacement for wildcard roulette - you know exactly what combination index 7 will produce, and you can batch over them.

The inputs that matter

  • tag_name - the variable's name, used for template replacement later (GENDER, AGE…). Leave it empty and the node auto-names itself (_VAR_xxxxxx) - useful when you're not using templates and don't care about conflicts.
  • values - one value per line. [NONE] (or a blank line) is the official "no value" option, which is how you build optional accessories.
  • randomize - the mode switch. OFF cycles through all values sequentially (this is what lets you batch over every combination). ON picks one at random each execution.
  • prefix / suffix - text glued before or after the chosen value. Great for building grammar into the value: a prefix of " and " on an accessory variable gives you "…in suit and glasses" without hand-writing every variant.
  • var_list (optional input) - connect the previous variable's var_list output here to enable conditional values (below).

The output is a single var_list - the variable data - which wires into Variable Folder, Variable Combiner, or Variable Builder.

The conditional superpower

This is where the node stops being a fancy list and becomes a real branching system. Connect a previous variable's var_list and your values can contain condition blocks:

suit
casual

[woman]
dress

[*]
sportswear

If GENDER resolved to "woman," the available pool becomes suit, casual, dress, sportswear; otherwise it's suit, casual, sportswear. The full syntax is genuinely expressive: [man&&young] for AND, [woman||old] for OR, [man&&!young] for NOT, [GENDER:man] to name the tag explicitly, and [*] to return to the common list. Recent versions add --only (replace all common values for that condition) and --value (exclude a specific value). Conditions are case-sensitive, and you must connect var_list - without it, no conditional logic, just the flat list.

How it fits a real workflow

For a simple setup: two or three Variable Prompt nodes → Variable Builder. For anything bigger, run them into a Variable Combiner first. The pack's examples show a character generator: GENDER × AGE × CLOTHING as sequential variables plus an ACCESSORY as random, combined into 18 distinct sequential prompts with a random accessory each run. That combination math - and the index control that drives it - lives in the Variable Builder, not here.

Installing it

Same pack install for every node here. ComfyUI Manager → search "ComfyUI-SBTools" → Install, or:

cd ComfyUI/custom_nodes
git clone https://github.com/Amatsukast/ComfyUI-SBTools.git
cd ComfyUI-SBTools
pip install -r requirements.txt

Restart ComfyUI. No models, no downloads - this is pure logic.

Troubleshooting

  • Conditions doing nothing - check you connected var_list from the previous variable, and that condition values match exactly (case-sensitive).
  • Duplicate tag names error downstream - two variables with the same tag_name but different values will error in the Combiner. Rename one, or leave tag_name empty for auto-naming.
  • A variable always picks the same value - it's in sequential mode with only one value, or it's on index 0 and you never increment.

If you've only ever used wildcards, this feels verbose at first - one node per variable instead of one string. The payoff is knowing exactly what you're generating and being able to batch every combination deterministically, which wildcards never give you.

CategorySBTools/Prompt

Inputs (7)

NameTypeDefaultDescription
tag_nameSTRINGTag name for template replacement (e.g., GENDER, CLOTHING)
valuesSTRINGvalue1 value2 value3List of values, one per line. Use [condition] syntax for conditional values (e.g., [man&&suit]).
randomizeBOOLEANfalseEnable random selection (off = sequential cycle through all values)
prefixSTRINGText to add before value (only in tag mode, ignored if value is empty)
suffixSTRINGText to add after value (only in tag mode, ignored if value is empty)
output_to_promptBOOLEANtrueInclude this variable in the generated prompt. Turn OFF to make it a control-only variable: it still picks a value and other variables can still branch on it, but it never appears in the output - not even if its [TAG] is written in the template.
var_listoptVARIABLE_LISTOptional: Connect previous variable to enable conditional logic based on its values

Outputs (1)

NameTypeDescription
VAR_LISTVARIABLE_LIST