π Text Input Switch (4 way)
Route one of four prompts based on a number β the batch-variation workhorse
- STRING
When you want to test four prompt ideas in one batch, the naive way is four separate copies of the whole pipeline. The sane way is one pipeline with a switch: an integer selects which of four text strings flows through, and you batch over that integer. That's ACE_TextInputSwitch4Way - four text inputs, one input selector, one string out. It's a control-flow node, and it's the boring piece that makes prompt A/B testing feel effortless.
It's part of π
Ace Nodes (hay86/ComfyUI_AceNodes), the usual one-author grab-bag. The pack also ships a 2-way and an 8-way version of the same idea; this one is the middle child and the one most people actually need.
How it works
input- an integer from 1 to 4 (note: 1-based, unlike the pack'sACE_TextSelector, which is 0-based - this inconsistency has bitten people). This is the selector.text1β¦text4- the four candidates. They're optional inputs markedforceInput, so the idiomatic setup is fourSTRINGwidgets or prompt-loader nodes wired in, then a singleinputdrives the choice.
The output is the STRING of whichever slot is selected. Nothing else happens - no merging, no logic, just routing. If you're 0-indexed in your head, input = 1 gives text1, and yes, it's easy to be off by one on the first try.
Why you'll reach for it
Batch variation, full stop. Wire input to a per-batch counter or a seed-derived integer and every item in a batch silently tries a different prompt - positive prompt, negative prompt, or subject swap. It also does duty as a manual "toggle" between two or four saved presets during interactive play. The pattern generalizes: a 4-way text switch plus a counter gives you prompt interpolation without any scripting.
Where people get tangled: using it as a boolean gate. It's not - it's a multiway selector, so "on/off" logic is better served by the pack's ACE_AnyInputSwitchBool, which works on any type including strings, or a dedicated boolean-switch node. And remember the inputs are strings; if you want to route images, latents, or models, that's the ACE_AnyInputSwitchBool / ACE_AnyInputToAny family, not this node.
Installing
ComfyUI Manager β search ComfyUI_AceNodes, or:
cd ComfyUI/custom_nodes
git clone https://github.com/hay86/ComfyUI_AceNodes
Then restart. Installing the pack drags in the whole requirements.txt (transformers, rembg, insightface, soundfile, β¦) even though this node is pure Python. The usual grab-bag tax.
Verdict: there are fancier prompt-switching nodes out there - ones with previews, random selection, weight blending - but if all you need is "pick one of four by an integer," this is exactly it, and it composes cleanly with the pack's text utilities. The 1-based indexing and the pack's inconsistent text-selector indexing are the only things that will ever bite you.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| input | INT | 11β4 | β |
| text1opt | STRING | β | |
| text2opt | STRING | β | |
| text3opt | STRING | β | |
| text4opt | STRING | β |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | β |