Nodes/Sage Utils/Logical Switch
ComfyUI Node

Logical Switch

A true/false fork that only runs the branch you actually picked

By arcum42·Created 2 years ago·Updated 22 days ago· 33
Logical Switch
  • true_value
  • false_value
  • result
conditiontrue

Switch nodes are everywhere in ComfyUI, and they all do roughly the same thing: pick between two inputs based on a condition. Logical Switch is Sage Utils' version, and its one genuinely useful trick is that it's lazy - only the branch you select actually gets evaluated. Pick false_value and ComfyUI never wastes time running the entire expensive branch hanging off true_value. In a graph with heavy model operations on both sides, that's the difference between a fast workflow and a pointless one.

That laziness is also why it's now deprecated. ComfyUI core shipped its own any-type switch with the same behavior, and when core covers a utility, a good pack retires its copy rather than duplicating it. The node still works - deprecated in this pack means "stable, superseded," not "broken."

How it works

You give it a condition (a boolean, default true), plus a true_value and a false_value - both are any-type inputs, so they can carry images, models, text, latents, whatever. The result output returns whichever branch matches the condition.

The lazy part: via ComfyUI's lazy-evaluation mechanism, the node tells the executor which input it actually needs before anything runs. If condition is true, only true_value is pulled from its upstream nodes. The other side of the graph - potentially a whole sampler branch - is never touched. It also validates up front that at least one branch is connected, so you can't silently configure a switch that has nothing to output.

What you actually set

  • condition - the toggle that chooses the branch.
  • true_value / false_value - the two candidates. Because they're any-type, both sides should hold the same kind of data (two images, two models, two strings) or your downstream node will complain.

One output: result.

Where it earns its keep

Batch loops are the sweet spot. In a loop that processes both a high-quality and a quick-pass version of something, the switch picks per iteration and the lazy behavior means the unselected branch isn't re-run every pass. It's also handy for A/B setups where you flip one boolean to route between two model branches. Honestly, for most simple "pick A or B" jobs, core ComfyUI's switch does the same thing - reach for this one when the cost of evaluating both branches is real, and you want the guarantee that only one runs.

Installing

It's Sage Utils, so:

cd ComfyUI/custom_nodes
git clone https://github.com/arcum42/ComfyUI_SageUtils.git
cd ComfyUI_SageUtils && pip install -r requirements.txt

Restart ComfyUI, or install via ComfyUI Manager ("Sage Utils"). No dependencies beyond the pack.

The honest note

Because it's flagged deprecated, newer ComfyUI interfaces may dim it in the node menu - it'll still be there, just visually demoted. If you're starting a fresh graph, the core switch (or the pack's newer switching utilities) is the better habit; but if you load an older workflow that references Logical Switch, it'll keep working without complaint. Same pattern as the pack's legacy join nodes - simple, stable, and quietly retired in favor of the ecosystem catching up.

CategorySage Utils/util

Inputs (3)

NameTypeDefaultDescription
conditionBOOLEANtrueChoose which branch to return.
true_valueopt*Value returned when the condition is true.
false_valueopt*Value returned when the condition is false.

Outputs (1)

NameTypeDescription
result*The selected branch value returned by the logical switch.