ComfyUI Node

IF A Else B

Real if/else routing in a workflow that loves pretending it has no logic

By r-vage·Created about a year ago·Updated 5 months ago· 23
IF A Else B
  • on_true
  • on_false
  • *
boolean

ComfyUI pretends it's a dataflow graph with no concept of "if this, then that." The IF A Else B node calls that bluff. It takes two candidate values and a boolean, and routes one of them through based on the boolean - a genuine conditional, not a manual switch you have to flip by hand. Wire the boolean to a real signal and your workflow starts making decisions on its own.

How it works

Three inputs, one output:

  • on_true - whatever you want passed through when the condition is true.
  • on_false - whatever you want passed through when it's false.
  • boolean - the condition. This is forceInput, so you can't type a value in; you have to wire it from somewhere that produces a true/false.

The mechanism couldn't be simpler: if boolean is true, output on_true; otherwise output on_false. And the key detail is that both inputs are any-type - the node doesn't care whether you're routing images, latents, conditioning, models, or strings. Whatever goes in one side comes out the other. That's the whole trick that makes it a workhorse: one generic conditional that handles every data type ComfyUI has.

Where it earns its keep

The obvious use is feeding it a boolean from a control node - a face-detection result, a "is this image empty" check, a front-end toggle - and letting it pick between two whole branches. Common patterns:

  • Route to different prompt text based on a condition (e.g., "this character is visible" → character prompt, else → background-only prompt).
  • Pick between two latent sizes or two sampler settings without manual rewiring.
  • Build a simple A/B toggle that drives which image goes to the upscaler.

Because the boolean input is a wire rather than a widget, you can't use this as a manual button the way you would a plain switch - but that's exactly what makes it useful for automated flows. If you just want a hand-flipped selector, the RvTools Image Switch / Latent Switch family is the manual version; this is the automated one.

A practical caveat

ComfyUI executes nodes when their inputs are ready, so a conditional doesn't make the "losing" branch free - the thing feeding on_false may still run, because its data has to exist before the decision can be made. This node routes data, it doesn't skip computation. That matters if you're hoping to gate a heavy operation behind a condition; for pure data selection it's fine.

Installing it

Part of the RvTools v2 pack - no models, pure utility. ComfyUI Manager → search RvTools → install ComfyUI-RvTools_v2, restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/r-vage/ComfyUI-RvTools_v2

Restart and watch for RvTools v2: Version 2.5.x in the console. Its requirements (opencv-python, pilgram, pynvml, piexif) are handled automatically by Manager.

Troubleshooting

Two things to keep in mind:

  • The boolean must be wired. Since it's forceInput, an unconnected boolean means the node can't run. If you get a red error on this node, that's usually it.
  • Old workflows referencing RvTools v1 will fail to install - the original repo was deleted, which is why this v2 pack exists with renamed nodes. And the author has since moved development to ComfyUI_Eclipse, which supersedes this pack.
Category🫦 RvTools II/ Switches

Inputs (3)

NameTypeDefaultDescription
on_true*
on_false*
booleanBOOLEAN

Outputs (1)

NameTypeDescription
**