ComfyUI Node

Switch Any

The node that powers 'if this, use that' workflows

By danipisca07·Created 6 months ago·Updated 6 months ago· 0
Switch Any
  • if_true
  • if_false
  • *
conditionfalse

Switch Any is the node that makes conditional workflows work. It takes a boolean condition, plus two candidates - if_true and if_false - and passes one through: if_true when the condition is true, if_false otherwise. And because its two candidate inputs are wildcard type (*), it works on anything: images, latents, models, conditioning, strings, you name it. That's why it's the most useful node in this pack.

Why you'd reach for it

ComfyUI workflows are graphs, not programs - there's no if statement. A switch is how you get branching: "use this prompt if the checkbox is on, that one if it's off." "Route to the hires pass when a condition is met." The killer feature of Switch Any over a typed switch is that you can branch on heavy, non-numeric stuff. Swap between two loaded models, two latent batches, two CLIP conditionings, two images - no conversions, no workarounds, just a boolean deciding which wire wins.

The condition doesn't have to come from a checkbox, either. Wire in the output of a Compare node ("is the width bigger than 1024?"), a logic gate like the pack's OR or NOT, or a Number → Bool conversion, and your workflow starts making decisions on its own.

How it works

The implementation is a single Python conditional - if_true if condition else if_false - with wildcard * sockets so ComfyUI lets anything in and returns whatever you fed it. The author's description: "Returns if_true when condition is True, otherwise returns if_false. Works with any type." It sits in SimpleLogics/Switch with the typed variants (Switch Int, Switch Float, Switch String).

The inputs that matter

Three required inputs:

  • condition - the BOOLEAN that decides which candidate wins
  • if_true - returned when condition is true (any type)
  • if_false - returned when condition is false (any type)

One wildcard output, which is whatever type you passed in.

Installing it

Part of danipisca07/ComfyUI-SimpleLogics, the dependency-free pure-Python pack - no requirements.txt, no models to download. Install from ComfyUI Manager (search "SimpleLogics") or:

cd ComfyUI/custom_nodes
git clone https://github.com/danipisca07/ComfyUI-SimpleLogics

Restart ComfyUI and you're set.

Common issues

The tradeoff of the wildcard type is that ComfyUI won't police your wiring as hard, so the classic bug is a type mismatch downstream - the switch happily passes an image through a socket that wanted a latent. Also worth knowing: newer ComfyUI builds ship their own basic Switch/logic nodes in core, so you can build some of this without the pack - but a lot of downloaded workflows still reference this one, and having it installed is what lets them load without missing-node errors. If both branches must be the same strict type, the typed Switch nodes in this pack give you cleaner sockets. And the usual quirk: installing SimpleLogics also registers an undocumented GeoCalib camera node - ignore it.

CategorySimpleLogics/Switch

Inputs (3)

NameTypeDefaultDescription
conditionBOOLEANfalse
if_true*
if_false*

Outputs (1)

NameTypeDescription
**