Nodes/ComfyUI Impact Pack/Switch (latent/legacy)
ComfyUI Node Runs on cloud

Switch (latent/legacy)

Pick one of several inputs to pass through

By ltdrdata·Created 3 years ago·Updated 4 months ago· 3,242
Switch (latent/legacy)
  • input1
  • selected_value
  • selected_label
  • selected_index
select1
sel_modefalse

LatentSwitch is the class name, but the node shows up in the menu as Switch (latent/legacy) - and while it started life as a latent switch, it's really the general-purpose "pick one input" switch. Many inputs go in, one comes out, and a select number decides which. It's a multiplexer: build two or three alternative branches, then flip a single number to choose which one feeds the rest of your workflow, without rewiring anything.

This is the everyday counterpart to Inversed Switch. Where Inversed Switch takes one input and routes it to one of many outputs, this takes many inputs and lets one of them through. A/B two samplers, keep a "high quality" and a "fast preview" path side by side, or gate optional stages - all just a matter of changing select.

How it works

You connect your candidate inputs to the input slots (they start at input1 and the node grows more slots as you wire them up), set select, and the node passes the chosen input straight through to its output. The inputs are wildcard-typed, so this works for latents, images, models, conditioning - whatever you plug in, as long as the branches are the same type. The unselected inputs are ignored, and thanks to ComfyUI's lazy evaluation the branches feeding them generally don't execute.

The inputs and outputs that matter

  • select (default 1, min 1) - which input slot to pass through. select: 1 passes input1, select: 2 passes input2, and so on. Note it's 1-indexed.
  • sel_mode (boolean) - whether select is read from the widget or taken live from a connected input each run. Turn it on when another node is driving the selection.
  • input1 (and additional slots that appear as you connect) - the candidate values. The first must be connected; wire more to grow the choices.

The outputs are selected_value (the chosen input, wildcard-typed - this is the one you route onward), plus selected_label (a STRING) and selected_index (an INT) that tell you what got picked, handy for debugging or logging which branch won.

How to install it

Part of the Impact Pack. ComfyUI Manager: search ComfyUI Impact Pack, Install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/ltdrdata/ComfyUI-Impact-Pack comfyui-impact-pack
cd comfyui-impact-pack
pip install -r requirements.txt

then restart. No extra dependencies.

Common issues & troubleshooting

Error when the selected input isn't connected. The README is blunt about this: the first input must be provided, and if select points at a slot you haven't wired, you'll get an error. Only route to slots that actually have something plugged in.

Off-by-one confusion. select is 1-indexed. Slot 1 is the first input, not slot 0. If you're getting the wrong branch, that's the usual reason.

Type-validation warnings. Like all Impact Pack switches, it uses a wildcard type to accept any input, which can produce cosmetic type-mismatch messages while still running fine. Just keep every branch the same type as each other - don't mix a latent input and an image input into one switch.

It's called "legacy." The label reflects that this is an older switch design kept for compatibility; the pack also offers the newer Switch (Any) family. For fresh workflows either works, but if you're following a modern tutorial it may point you at the Any variant.

CategoryImpactPack/Util

Inputs (3)

NameTypeDefaultDescription
selectINT11–999999The input number you want to output among the inputs
sel_modeBOOLEANfalseIn the case of 'select_on_execution', the selection is dynamically determined at the time of workflow execution. 'select_on_prompt' is an option that exists for older versions of ComfyUI, and it makes the decision before the workflow execution.
input1opt*Any input. When connected, one more input slot is added.

Outputs (3)

NameTypeDescription
selected_value*Output is generated only from the input chosen by the 'select' value.
selected_labelSTRINGSlot label of the selected input slot
selected_indexINTOutputs the select value as is