Nodes/ComfyUI_AceNodes/πŸ… Text Input Switch (4 way)
ComfyUI Node

πŸ… Text Input Switch (4 way)

Route one of four prompts based on a number β€” the batch-variation workhorse

By hay86Β·Created 2 years agoΒ·Updated about a year agoΒ· 96
πŸ… Text Input Switch (4 way)
    • STRING
    β—„input1β–Ί
    β—„text1β–Ί
    β—„text2β–Ί
    β—„text3β–Ί
    β—„text4β–Ί

    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's ACE_TextSelector, which is 0-based - this inconsistency has bitten people). This is the selector.
    • text1 … text4 - the four candidates. They're optional inputs marked forceInput, so the idiomatic setup is four STRING widgets or prompt-loader nodes wired in, then a single input drives 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.

    CategoryAce Nodes

    Inputs (5)

    NameTypeDefaultDescription
    inputINT11–4β€”
    text1optSTRINGβ€”
    text2optSTRINGβ€”
    text3optSTRINGβ€”
    text4optSTRINGβ€”

    Outputs (1)

    NameTypeDescription
    STRINGSTRINGβ€”