Nodes/SP-Nodes/SP_SwitchBooleanAny
ComfyUI Node

SP_SwitchBooleanAny

A boolean-driven if/else for any type

By bananasss00·Created 2 years ago·Updated 5 days ago· 20
SP_SwitchBooleanAny
  • on_true
  • on_false
  • *
booleantrue

Every graph-based tool eventually needs a plain if/else, and ComfyUI's node system doesn't have branching baked in as a language feature - you build it out of nodes. SP_SwitchBooleanAny is SP-Nodes' version of that: the simplest possible conditional switch.

What it does

Three required inputs - on_true, on_false, both typed as "any," and boolean, a checkbox defaulting to true - and one output, also "any." When boolean is checked, the node passes on_true through; unchecked, it passes on_false. That's the entire mechanism. No hidden behavior, no edge cases beyond what a ternary expression would have in any programming language.

Where you'd use it

Anywhere you want to flip between two options without physically rewiring the graph - two different prompts, two different LoRA stacks, two candidate images, two model checkpoints. Wire both possibilities in ahead of time, drive boolean from wherever your condition actually lives (a manual toggle, or the output of some other logic upstream), and the switch does the routing. It's especially handy paired with something that computes a boolean dynamically - you get an actual conditional workflow instead of two separate workflows you swap between by hand.

One honest note on style, not correctness: nodes that accept "any" type on both sides make graphs flexible, but they also make graphs harder to read at a glance - you can't tell what's flowing through a wire without clicking into it, which is exactly the complaint the ComfyUI community has raised about loose any-to-any routing nodes in general. That's not a reason to avoid SP_SwitchBooleanAny - a genuine conditional branch is worth the tradeoff - just a reason to label your nodes and keep the branches short enough that six months from now you can still tell what each side does.

Installing it

Ships with the rest of the SP-Nodes pack:

  • ComfyUI Manager: search "SP-Nodes", install, restart.
  • Manual: cd ComfyUI/custom_nodes && git clone https://github.com/bananasss00/ComfyUI-SP-Nodes, restart ComfyUI.

No models, no extra dependencies - it's a few lines of branching logic.

Troubleshooting

Because both branches and the output are typed "any," ComfyUI's type checker won't stop you from wiring two genuinely incompatible things into on_true and on_false - say, an image on one side and a string on the other. That will work fine right up until whatever's downstream tries to use the output and gets a type it didn't expect. If a downstream node throws a confusing type error after adding this switch, check that both branches are actually feeding the same kind of thing before assuming the switch itself is broken. Beyond that, there's nothing subtle here - if the wrong branch keeps firing, it's almost always the boolean input evaluating differently than you expect, not the switch logic itself.

CategorySP-Nodes

Inputs (3)

NameTypeDefaultDescription
on_true*
on_false*
booleanBOOLEANtrue

Outputs (1)

NameTypeDescription
**