Nodes/ComfyUI-BCNodes/Select Switch
ComfyUI Node

Select Switch

A Switch You Pick By Name, and Only the Branch You Pick Runs

By 0xBeycan·Created about a month ago·Updated 13 days ago· 2
Select Switch
    • *
    ◄selected▾►

    Every packing list of "nodes you actually need" starts with a switch, and there are already a dozen of them. Here's why this one is worth a look anyway: its options are named, you can have as many as you want, and the unselected branches are never executed.

    The shape it is

    ComfyUI switches come in two shapes. A/B switches have a selector - a boolean or an index - and pass whichever input you point at. Fallback switches have no selector at all: they walk their inputs and pass the first one that isn't empty, which is what rgthree's Any Switch does. (The plumbing essay in comfyui-node-plumbing.md lays the taxonomy out properly; both shapes exist because the two jobs are different.)

    Select Switch is firmly the first shape, but the selector is a combo of names rather than a number. If you've built a graph with six parallel experiment branches and you keep losing track of which index is the "with-ControlNet" one, this fixes that specific annoyance. Renaming an option keeps the link; the list of options is saved with the workflow; the socket type follows whatever you connect, because the inputs are wildcard *.

    The part that matters more than the naming

    Only the selected option's branch runs.

    That's the whole reason to prefer it over a plain A/B switch. Connect one image to two expensive upstream paths - a full detailer pass and a fast plain one, say - and route both into this node. Queue it with option A selected and the detailer's chain runs; queue it with B and it never does. No wasted VRAM, no wasted minutes. The node declares its option inputs as lazy, so the executor skips everything the unselected socket depends on.

    The technical sticker is that ComfyUI's built-in "this value isn't in the combo's list" validation doesn't work for a combo whose values live on the canvas, so the node replaces it with its own check. Practically, that means the error messages are the pack's, and they're decent: selecting an option you haven't connected raises and names the option, rather than handing you a None and letting it explode three nodes later.

    Using it

    There is no fixed input list - options are created on the node with a + Add option button, each one asking for a name, and each one becomes a row under the selected combo. That matches the schema you'll see in the docs: exactly one declared input, selected, and one output, *. Click a row's name to rename it (the link survives), ✕ to remove it. Empty names, duplicates, and the reserved names selected and self are refused.

    Wire the output anywhere; the type is whatever you connected.

    Two things worth knowing if you're driving graphs programmatically: selected can be promoted out of a subgraph, and it can be fed by a STRING or COMBO output, so an upstream text node can decide which branch runs. Point it at anything that isn't a string-style output and it tells you so instead of guessing.

    Install

    Same pack, same steps as every other node here. Manager, searching ComfyUI-BCNodes, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/0xBeycan/ComfyUI-BCNodes
    pip install -r ComfyUI-BCNodes/requirements.txt
    

    Restart, then type BCNodes into the node-library search to see the pack's nodes together (this one lives under BCNodes/logic). The requirements are opencv-python, postfx and caption-audit; none of them is needed for this node. Delete any old ComfyUI-AutoBypass folder from the pack's previous name.

    Gotchas

    Because the unselected branches genuinely don't run, their outputs stay empty - and if some other node downstream also consumes the branch you didn't select, it'll be empty too. That's correct behaviour and it looks exactly like a broken workflow. Keep the branches converging on this node rather than leaking sideways.

    Second: since only the selected branch is evaluated, changing selected between queues is not free the way you might hope - the newly selected branch runs from scratch. Fine for "run the good pass this time", less fine as a per-frame toggle inside a long video job.

    Third, a mild one: the wildcard type means ComfyUI can't warn you when you've connected something that makes no sense to the consumer. That's the price of any-type sockets, and it applies to every switch in the ecosystem.

    CategoryBCNodes/logic

    Inputs (1)

    NameTypeDefaultDescription
    selectedCOMBOThe option whose input is passed to the output. Only that input's branch runs.

    Outputs (1)

    NameTypeDescription
    **—