ComfyUI Node

Switch

A boolean switch that only runs the branch you actually pick

By aesethtics·Created about a year ago·Updated about a year ago· 1
Switch
  • input_0
  • input_1
  • input_2
  • input_3
  • input_4
  • input_5
  • input_6
  • input_7
  • selected
index0

The first time you wire two alternative pipelines into a sampler you discover that most "switch" nodes are liars: they pick one value at the end but ComfyUI has already executed both branches, burning your VRAM and your patience. UtilSwitch does it the honest way - with lazy evaluation, so only the branch you select actually runs. Flip a boolean and the other side of the graph simply never executes. That's not a small optimization when one branch loads a second ControlNet or a heavy LoRA.

How it works

Three inputs: on_true, on_false, and boolean_switch. When the boolean is true you get on_true out; false gives on_false. The mechanism underneath is ComfyUI's lazy-input protocol: the node implements check_lazy_status, which tells ComfyUI exactly which input it needs. If the boolean says true, it requests on_true and ComfyUI skips everything feeding on_false. That's the whole trick - and it's why the node can carry ANY-typed values: model, latent, image, conditioning, whatever, all pass through unchanged.

The inputs and output

  • boolean_switch (BOOLEAN, default true) - the selector. Toggle it or wire it from a condition node.
  • on_true (ANY, lazy) - value returned when the switch is on.
  • on_false (ANY, lazy) - value returned when the switch is off.
  • output (ANY) - the winning value.

Because both branches are lazy, you can even leave one unconnected - if the boolean points at the missing side, ComfyUI just skips it and the output is None.

Where it shines

A/B testing is the classic case: two sampler paths or two prompt strategies, one toggle to switch. So is routing around expensive nodes - "use the upscaler when this checkbox is set, bypass it when not." It pairs naturally with this pack's UtilBypass: the switch picks which branch, the bypass kills the dead branch's upstream. They're different tools for the same war on wasted VRAM.

One thing it does not do is choose among more than two options - that's what the pack's UtilSwitchCase is for, letting you pick one of up to eight inputs by index, also lazily. And note this is a value-level switch, not a node-mode toggler; if you want to flip an entire upstream node into ComfyUI's native bypass mode, that's Bypass territory again.

Install

Ships in the IXIWORKS pack - ComfyUI Manager → search ComfyUI-VideoDescription → Install, restart, or clone into custom_nodes/. No extra dependencies. If you've been faking binary routing with mute buttons, this is the node that makes it real - and saves you the seconds-to-minutes of pointless compute on the branch you weren't even using.

CategoryUtilitools/Logic

Inputs (9)

NameTypeDefaultDescription
indexINT00–7
input_0opt*
input_1opt*
input_2opt*
input_3opt*
input_4opt*
input_5opt*
input_6opt*
input_7opt*

Outputs (1)

NameTypeDescription
selected*