If ANY return A else B
The ComfyUI switch that actually works
- ANY
- IF_TRUE
- IF_FALSE
- ?
This is the node the pack is actually known for: a three-input switch that hands you back one of two values depending on a condition. The name is the whole spec - if ANY is true, you get IF_TRUE; otherwise you get IF_FALSE. In the code it's a one-liner: return (IF_TRUE if ANY else IF_FALSE,). That's it. No API, no models, no magic.
The reason it exists is a quirk of how ComfyUI thinks. A lot of beginners assume you can wire a condition into a node to make it skip itself. You can't - the graph runs everything that's connected, and an "if" has to be a value selector rather than a flow controller. This node is that selector: both branches feed it, it runs every time, and the downstream node only ever sees the one it picked.
The three inputs
- ANY - the condition, and it's a wildcard (
*), so you can wire nearly anything into it: aBOOLEANfrom the pack'sCompareorBoolnodes, an integer, a string. The node just tests Python truthiness. - IF_TRUE - the value returned when
ANYis truthy. - IF_FALSE - the value returned otherwise.
The output is a wildcard named ?, and the author's own tooltip describes it exactly: "Based on the value of ANY, either IF_TRUE or IF_FALSE will be returned." What you put into IF_TRUE and IF_FALSE is what comes out - prompts, seeds, numbers, even whole images from two different sampler branches.
Where people get burned
Truthiness is Python truthiness. Empty strings, 0, empty lists and dicts are all falsy, so "false" can sneak in through an empty prompt box. And here's the sharp edge: don't wire an image or latent into ANY. In the code, if ANY runs a plain Python truth test, and a multi-element tensor raises RuntimeError: Boolean value of Tensor with more than one element is ambiguous - a hard crash, not a silent wrong answer. Feed ANY from Compare or Bool (both give you a clean BOOLEAN), or any scalar.
Both branches run. The classic confusion: "why did my workflow still generate from the false branch?" Because ComfyUI executed it - this node just didn't pass its result along. If you want to actually stop work happening, you want a bypass, not a logic node. (rgthree-comfy's Fast Groups Bypasser is the common way; the KB's ecosystem essay calls this "organising the graph" vs. generating.)
How you'd use it
The pattern that shows up in the community over and over: compare two values, then switch behavior. A real example people hit - check if an image is taller than it is wide, then pick one resize path for portrait and another for landscape. Compare produces the BOOLEAN, it feeds ANY, and two pre-built options sit in IF_TRUE / IF_FALSE.
Install
Via ComfyUI Manager (search ComfyUI-Logic), or:
cd ComfyUI/custom_nodes
git clone https://github.com/theUpsider/ComfyUI-Logic
Then restart ComfyUI. There's no requirements.txt and nothing to download - the whole pack is one Python file. Just be aware the repo header says it's "currently not maintained," so don't expect fixes. For simple switching this node works fine regardless; the core "If" that ships with ComfyUI itself is the more future-proof alternative if you're starting fresh.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| ANY | * | — | |
| IF_TRUE | * | — | |
| IF_FALSE | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| ? | * | Based on the value of ANY, either IF_TRUE or IF_FALSE will be returned. |