๐ If-Else (input / compare_with)
Branch a workflow on a comparison
- input
- send_if_true
- send_if_false
- output
- rejected
- input_type
- true_or_false
- details
Comfy graphs are dataflow, not code, so "do X if the checkpoint is SDXL, otherwise do Y" isn't something the base engine gives you. If-Else adds it. You give it a value, a thing to compare against, and two payloads - one to forward if the comparison is true, one if it's false - and it routes the right payload through. The classic use, and the one in the docs: pick a different empty-latent size depending on whether you're running SDXL or SD1.5, off a single string that names the model.
It's genuinely handy for building "smart" workflows that adapt instead of hard-coding one path. The catch is that both branches still execute - this routes a value, it doesn't skip computation - so keep your expectations calibrated.
How it works
The node evaluates input against compare_with using whichever test you pick in input_type, gets a true or false, and forwards send_if_true or send_if_false accordingly on the output port. The rejected payload comes out a second rejected port. Everything is typed * (wildcard), so you can pass literally anything through - a latent, an image, a string, a number - as long as the receiving node accepts that type. And they chain: connect one If-Else's output into the next one's send_if_false to build a multi-way switch, like choosing between three resolutions.
The inputs and outputs that matter
input(*) - the value being tested.input_type- the comparison to run. Eight options: string equal / not-equal, boolean is-true / is-false, and number greater / greater-or-equal / less / less-or-equal. This is the knob that decides what kind of test happens, so set it to match your data.compare_with(STRING) - what you're testing against. For number comparisons it's read as a number; for the boolean tests it's ignored.send_if_true(*) - forwarded when the test passes.send_if_false(*, optional) - forwarded when it fails; if you leave it unconnected, the node returnsNoneon that branch.
Outputs: output (the chosen payload), rejected (the other one), input_type (echoes the test used), true_or_false and details (strings describing what happened - wire these into a Show node while you're debugging).
How to install it
ComfyUI Manager โ Bjornulf_custom_nodes โ install โ restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/justUmen/Bjornulf_custom_nodes
pip install -r Bjornulf_custom_nodes/requirements.txt
then restart. Pure logic, no special dependency - it loads regardless of the pack's optional packages.
Common issues & troubleshooting
Both branches ran anyway. This is the big conceptual gotcha. If-Else routes a value; it does not prune the graph. If your two payloads are outputs of expensive nodes, both nodes still compute - you're just choosing which result flows on. It's not a way to skip a KSampler.
My number comparison behaves like a string. input_type has to match the data. Feed a number test and make sure input and compare_with are actually numeric; a stray space or a value that's secretly a string will compare wrong. Wire details into a Show node to see exactly what it evaluated.
String equality never matches. Whitespace and case bite here. "SDXL " isn't "SDXL". Trim upstream, and remember the model-folder trick - the pack's Model Selector can hand you a clean folder name (like SDXL) to compare against.
send_if_false gave me None and broke the next node. That's the documented behaviour when it's left unconnected. Either connect a real fallback or chain it into another If-Else that handles the None case.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| input | * | โ | |
| input_type | COMBO | STRING: input EQUAL TO compare_with | 8 options: STRING: input EQUAL TO compare_with, STRING: input NOT EQUAL TO compare_with, BOOLEAN: input IS TRUE, BOOLEAN: input IS FALSE, NUMBER: input GREATER THAN compare_with, NUMBER: input GREATER OR EQUAL TO compare_with, +2 |
| send_if_true | * | โ | |
| compare_with | STRING | โ | |
| send_if_falseopt | * | โ |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| output | * | โ |
| rejected | * | โ |
| input_type | STRING | โ |
| true_or_false | STRING | โ |
| details | STRING | โ |