ComfyUI Node

🔄 Switch

Pick between two values with a boolean, wire type doesn't matter

By StableDiffusionVN·Created 2 years ago·Updated 29 days ago· 118
🔄 Switch
  • true
  • false
  • output
targettrue

Switch is the wiring-level version of an if/else: give it two candidate values and a boolean, and it forwards whichever one target points at. It doesn't care what the values are - images, strings, model pipes, latents, anything - because both input sockets are typed as wildcards. That makes it the go-to node for toggling between two whole branches of a workflow (two checkpoints, two style presets, an SDXL path versus a Flux path) without maintaining duplicate downstream wiring for each.

It's part of the SDVN Comfy Node pack's flow-control family, grouped in the README alongside Boolean, Logic Switch, and Auto Switch - Switch is the plain manual one, where you flip target by hand or drive it from an upstream condition; the others in the family presumably cover more elaborate cases (multi-way logic, automatic condition detection) that this simple version isn't trying to solve.

How it works

There's no transformation happening to either value - Switch just decides which of the two upstream results gets passed through to output, based on target. Nothing about the chosen value changes in transit.

Inputs and outputs

  • true (wildcard *, required) - the value forwarded when target is true.
  • false (wildcard *, required) - the value forwarded when target is false.
  • target (BOOLEAN, default true) - the switch itself. Flip it by hand, or wire it from another node's boolean output to drive the decision automatically.
  • output (wildcard *) - whichever of true/false got picked.

Where you'd actually use it

Anywhere you want one toggle to reroute a whole section of a graph: switching between two loaded models, two prompt sources, an "use ControlNet" versus "skip it" branch, or an A/B comparison you're flipping back and forth while testing. Because the type is wildcard, it composes with essentially anything else in the pack or in core ComfyUI.

Common issues

Type mismatches only show up at runtime, not at graph-build time. Because true and false are typed *, ComfyUI won't warn you if you wire an IMAGE into one and a STRING into the other - whatever's connected to output has to be able to handle whichever type actually shows up, or you'll get an error when the workflow runs rather than when you connect the wires.

Switching doesn't skip the unchosen branch's compute. Both true and false are required inputs the node declares it needs, so unless the node specifically opts into ComfyUI's lazy-evaluation hooks, the upstream chain feeding the value you didn't pick generally still runs. Switch decides which result reaches downstream - it isn't a shortcut around running the other branch, so don't rely on it to save GPU time the way a real conditional would in code.

Category📂 SDVN/💡 Creative

Inputs (3)

NameTypeDefaultDescription
true*Giá trị khi điều kiện True.
false*Giá trị khi điều kiện False.
targetBOOLEANtrueĐiều kiện lựa chọn.

Outputs (1)

NameTypeDescription
output*Kết quả lựa chọn.