π IF (Condition Selector)
The IF Node That Actually Lets Your Workflow Think
- A
- B
- TRUE_IN
- FALSE_IN
- *
ComfyUI's stock nodes are a straight-line graph: generate, refine, save. The moment you want to do different things depending on what just happened, you need a branch - and IfConditionSelector (π IF (Condition Selector), from ControlFlowUtils) is the node that makes branching feel natural instead of like a fight with the graph.
Here's the mental model. You feed it two values, A and B. It compares them however you ask. Then it forwards one of two inputs - TRUE_IN or FALSE_IN - depending on whether the comparison came out true. Whatever comes out the other side is what the rest of your workflow sees.
The inputs that matter
- condition - the comparison to run. There are 18 of them, and most are obvious:
A is TRUE,A == B,A > B,A in B,A is B, and so on. The last one, CUSTOM, unlocks the real power (more below). - require_inputs - this is the toggle that changes what the node is. On (default), the node needs TRUE_IN and FALSE_IN and forwards whichever one matches the result. Off, it forgets about inputs entirely and just outputs a raw
TrueorFalseboolean. - NOT - inverts the result. Handy when the condition you want is "everything except this."
- A and B - the two things to compare. Anything can go in: strings, ints, tensors, whatever.
One input and one output come out: *, meaning "the forwarded input or the boolean, depending on require_inputs."
The genuinely nice bit is lazy evaluation. Only the inputs the condition actually needs get executed. If the condition is A > B, ComfyUI won't run whatever feeds FALSE_IN at all. That's how you build a workflow that loads a heavy model on one branch only when a condition is true - the losing branch never runs, so it never costs you VRAM or time. It's the same execution-inversion machinery that makes this pack's loops possible.
Going custom
Set condition to CUSTOM and you get a custom_expression box with a Python-like expression (default 2*a == 5*b+2). In there, a and b refer to the A and B inputs, and you can also reference any variable you've saved in a ControlFlowUtils Memory Storage node by name. Want to check "did we already generate this seed?" - that's a custom expression with a stored variable. Note the constraint baked into the description: when the condition is CUSTOM, A and B must not be None, or it'll error.
One trap worth knowing: the A & B, A | B, A ^ B conditions are bitwise operators. On booleans they behave like and/or/xor, but feed them integers and you're doing bit math, which is probably not what you meant. And watch the difference between A == B (value equality) and A is B (identity) - for strings and numbers you almost always want ==.
Install and troubleshooting
The node ships in the ControlFlowUtils pack:
# ComfyUI Manager β Install Custom Nodes β search "ControlFlowUtils"
# or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/VykosX/ControlFlowUtils
Restart, then look under πΊ VykosX-ControlFlowUtils. No extra dependencies - the pack installs bare. If a branch isn't firing, the usual suspects are: you left require_inputs on but didn't wire both TRUE_IN and FALSE_IN, or you forgot that an unset input is None and A > B with a None operand errors rather than evaluates false. And if the whole pack fails to load at startup, update ComfyUI - the lazy-evaluation and blocking features need a recent core, and older builds throw "please update your ComfyUI" style errors.
This is one of the few nodes that, once you've used it, you'll wonder how you lived without it. Pair it with this pack's Universal Switch or Memory Storage and you can build workflows that genuinely route themselves.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| condition | COMBO | Condition to evaluate. The output will be set to the result. | |
| require_inputs | BOOLEAN | true | Enable to forward TRUE_IN/FALSE_IN Inputs of this node, disable to return Boolean results |
| NOT | BOOLEAN | Invert the result of the condition post-evaluation | |
| custom_expression | STRING | 2*a == 5*b+2 | Custom expression used with the CUSTOM Condition |
| Aopt | * | First Input to Evaluate | |
| Bopt | * | Second Input to Evaluate | |
| TRUE_INopt | * | Input to forward if the expression evaluates to True | |
| FALSE_INopt | * | Input to forward if the expression evaluates to False |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| * | * | Result of the comparison. Either a forwarded input or a boolean value depending on whether Required_Input is set |