If
The graph as a tiny program — If routes one of two values based on a condition
- true
- false
- value
You've got a boolean - a checkbox, a comparison result, a value from somewhere upstream - and you want the graph to behave differently based on it. That's what If is for: two inputs, a condition, and it passes whichever input the condition selects. The ComfyUI equivalent of an if/else, bolted onto the canvas.
The mechanism is exactly what you'd hope: if condition: return (true,) else: return (false,). Nothing clever, nothing hidden. The two value inputs are typed * - ComfyUI's wildcard/ANY type - which means they accept anything: images, latents, strings, models, conditionings. If doesn't care what it's routing; it just routes. That wildcard behavior is the standard engine mechanism the KB's node-plumbing doc describes: "*" inputs accept any source, and the node is expected to make sense of whatever it receives. Here the node doesn't have to make sense of anything - it just passes it through untouched.
The inputs:
- true - passed through when the condition is true.
- false - passed through when the condition is false.
- condition - a
BOOLEANinput (default checkboxes and comparison nodes feed this).
The output:
- value - whichever of the two inputs the condition picked.
Here's the honest caveat, and it's an important one: this node routes data, it doesn't gate execution. In ComfyUI, every upstream node that's wired in runs (subject to the engine's caching) - If just decides which result travels onward. So don't expect it to save compute by "skipping" an expensive branch; it won't. If your expensive branch is wired into the true input, it still runs, you just don't get its output. If you genuinely want to skip work, a bypass or a muter is the tool, not this.
Where it fits: A/B selection between two checkpoints or two LoRA stacks, picking a prompt based on a toggle, routing different images down different post-processing paths. In the plumbing taxonomy this is the A/B switch family, and for a graph that's starting to feel like a program, it's one of the first nodes you reach for.
One thing to set up before it's useful: you need a boolean source. If you don't have one, convert a checkbox widget on another node to an input, or use a comparison/boolean node from another pack - FairLab doesn't ship a dedicated boolean constant, so the condition socket has to be fed from somewhere.
Install is the standard pack path: ComfyUI Manager → search ComfyUI-FairLab → install → restart:
cd ComfyUI/custom_nodes
git clone https://github.com/yanhuifair/ComfyUI-FairLab.git
cd ComfyUI-FairLab
pip install -r requirements.txt
Restart, search "If" or "conditional". No models, no dependencies - it's a return statement with a condition in front of it.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| true | * | — | |
| false | * | — | |
| condition | BOOLEAN | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| value | * | — |