Nodes/ComfyUI/If/Else Switch
ComfyUI Node Runs on cloud

If/Else Switch

The conditional node ComfyUI finally shipped

By Comfy-Org·Created 4 years ago·Updated 29 minutes ago· 129,853
If/Else Switch
  • on_false
  • on_true
  • output
switch

For years, if you wanted a workflow that took one path or another based on a condition, you installed a third-party pack. ComfyUI-Logic, rgthree's Any Switch, Impact Pack's ConditionalBranch - the community built a dozen of them because core simply didn't have one. In late 2025 ComfyUI finally shipped its own: If/Else Switch. It's the cleanest way to answer the single most-asked workflow question: "can it load checkpoint A when this toggle is on, and checkpoint B when it's off?"

Yes. Yes it can. That's the whole point.

How it works

The node has a switch toggle and two data slots, on_true and on_false. If the toggle is on you get on_true out; off, you get on_false. Under the hood it's one line of Python: on_true if switch else on_false.

What makes it special is the MatchType on those slots. Instead of being locked to one data type, the node adopts whatever type you connect. Wire a checkpoint into on_true and the node becomes a model router - on_false now only accepts a checkpoint too, and the output is a checkpoint. Wire two prompts in and it's a text router. Two images, two LoRAs, two VAE files: one node, any type. That's the "16-nodes-in-1" trick.

The other big deal is lazy evaluation. ComfyUI only runs the branch that's actually taken. If the switch is off, everything upstream of on_true never executes - no wasted compute, and no errors from a branch you weren't using anyway. That's genuinely useful, not just a speed nicety.

The inputs that matter

  • switch (BOOLEAN) - the toggle. Flip it by hand, or wire it from anything that outputs a boolean: a comparison node, a Not node, a string-length check. This is where a workflow becomes "smart" instead of "manual."
  • on_true / on_false (any type) - the two candidates. Both are required; the MatchType template means they must be the same type.
  • output - whatever you wired in, passed through untouched.

How you get it

It ships with ComfyUI core - no install, no Manager, no git clone. It landed in the core codebase in December 2025 and is still flagged experimental, so keep ComfyUI updated; the node itself shouldn't change dramatically, but the surrounding schema has been evolving.

Common issues

It won't let me connect the second branch. Type mismatch. Connect on_true first, then the other slot locks to that type - if you try to feed an image into one branch and a model into the other, the second connection gets rejected. That's by design; the output can only be one type.

My branch never runs. Check the toggle's actual value, and remember lazy evaluation: if you expected both branches to execute for side effects, that's not how it works. The unused one genuinely doesn't run.

It breaks a workflow I downloaded. It's new and experimental, and a few older packs still fight with it. The community lesson from the Nodes 2.0 mess is worth repeating: don't build a workflow on 50 instances of an experimental node if a stable alternative exists. For most people this is the better alternative - but treat it as new, not as the old reliable.

Categoryutilities/logic

Inputs (3)

NameTypeDefaultDescription
switchBOOLEAN
on_falseCOMFY_MATCHTYPE_V3
on_trueCOMFY_MATCHTYPE_V3

Outputs (1)

NameTypeDescription
outputCOMFY_MATCHTYPE_V3