Variable Builder (SBTools)
The output node of the variable system — assemble prompts from tags and wire in up to four images
- var_list
- PROMPT
- IMAGE1
- IMAGE2
- IMAGE3
- IMAGE4
Every variable system needs a payoff node - the place where all those Variable Prompt and image-loader lists finally become a usable prompt. That's Variable Builder. It takes the combined variable list, resolves it to one specific combination, replaces the tags in your template, and hands you the finished prompt string plus up to four loaded reference images. It's the last stop before your text encoder and your image reference inputs.
If you've only got a couple of variables, you could connect them straight into this node. With more than a handful, run them through a Variable Combiner first and feed that in - the Builder doesn't care how many variables the list contains, it just resolves them.
The inputs that matter
template- your prompt skeleton with[TAG_NAME]placeholders:"A [AGE] [GENDER] wearing [CLOTHING]."Leave it empty for simple join mode, which just concatenates all the values with the separator.index- selects which sequential combination to produce (loops automatically). Drive this from a Primitive (INT, increment) and you can step through every combination in order - this is how the batch runs work.seed- seeds the random text variables. Image variables keep their own seeds, so a random body image isn't yanked around when you change the prompt seed.separator- how values are joined (default", "). Matters in join mode and for unused variables.var_list- the variable data from Variable Prompt, Variable Image Loader, Variable Folder, or a Combiner.
Outputs
PROMPT- the finished string. Wire it into your CLIP/text-encode node (or a Show Text to inspect it).IMAGE1–IMAGE4- the resolved images, for reference-image workflows (FLUX.2 Reference and similar). Unused slots are filled with blank 64×64 images, so you can always wire all four without errors.MAX_COMBINATIONSandALL_COMBINATIONS- the total pattern count and a debug listing of every combination. Note: v2.0 of the pack moved these to a separate Variable Debug node, so on a current install you'll find them there instead - the Builder's remaining outputs are the prompt and images.
The debug outputs are genuinely useful while you're building: ALL_COMBINATIONS shows you every resolved pattern with its index number, which turns "which combination was this?" into a lookup instead of a guessing game.
How it fits a real workflow
The README's headline example is a character batch: GENDER (2) × AGE (3) × CLOTHING (3) sequential values, plus a random accessory - 18 combinations. Increment index and each run emits the next prompt: "A young man in suit and glasses." Add image variables and the math extends - 3 styles × 4 poses × 5 body images × 3 face images = 180 combinations, with the right images landing in IMAGE1/IMAGE2 for each prompt. The pack advertises that enumeration of 10,000+ combinations is fast (under a second), which keeps large matrix runs practical.
Installing it
Standard pack install. 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 model downloads - it loads images from disk and does string assembly.
Troubleshooting
- Prompt comes out empty -
var_listisn't connected, or every variable resolved to[NONE]. Check your wires first. - Tags left literal in the output - a
[TAG]in the template with no matching variable (or a misspelled tag name). The Builder only replaces what exists. - Images in the wrong slots - variable order in the combined list determines slot order; reorder the Combiner inputs to control it.
- Looking for the combination count on a new install - it moved to the Variable Debug node in v2.0; check there.
This is the node that turns the whole system from "a bunch of list nodes" into "a batch prompt generator with matching references." Get the template right and the index wired to an increment, and you've automated an entire character sheet.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| template | STRING | Template text with [TAG_NAME] tags (e.g., 'A [AGE] [GENDER][CLOTHING].'). Leave empty for simple join mode. | |
| index | INT | 00–999999 | Index to select which Sequential combination (loops automatically) |
| seed | INT | 00–4294967295 | Seed for Random TEXT variables (Image Variable has its own seed) |
| separator | STRING | , | Separator to join values (used for unused variables and empty template mode) |
| var_listopt | VARIABLE_LIST | Variable list from Prompt Variable, Image Variable Loader, or Variable Combiner |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| PROMPT | STRING | — |
| IMAGE1 | IMAGE | — |
| IMAGE2 | IMAGE | — |
| IMAGE3 | IMAGE | — |
| IMAGE4 | IMAGE | — |