If/Else (NH)
Your graph's if/else, with both sides always wired
- if_true
- if_false
- result
- condition_out
If you've ever built "two prompts, one condition, pick one" by hand - a boolean feeding two mute toggles and a reroute - you've reinvented If/Else (NH) badly. This is the version that does it in one node: a condition boolean, an if_true value, an if_false value, and a result that is whichever one the condition says. That's the entire job, and it's the most-reached-for logic node in the pack because it's the one you can explain to yourself at 2 a.m.
How it works
Three inputs, two outputs, no cleverness:
- condition - the boolean that decides.
- if_true / if_false - both are
*wildcard inputs, so they can carry any type: images, latents, prompts, models. This is what makes the node usable as a universal picker rather than a string-only thing. - result - the selected value.
- condition_out - the condition echoed back out, so you can chain decisions without re-wiring the boolean source.
The practical consequence of the wildcard inputs: you can feed two different prompt strings into it to switch prompts, two different latents to switch starting points, or two models to switch checkpoints. Same node, same wiring shape, different data.
It composes with everything in the logic family. Compare (NH) produces the condition (batch index > 5), If/Else picks the value, Gate Switch (NH) blocks expensive branches. You can build a surprisingly complete state machine out of these three nodes.
What it is not
It is not lazy, and it is not a fallback. Both if_true and if_false are evaluated, and the node does no "first non-null" logic - if the condition is false it passes if_false even if if_false is empty. For fallback behavior, look at a first-non-null switch instead. And if your concern is compute - you don't want the loser branch running at all - reach for Any Switch (NH) (the A/B selector with lazy evaluation) rather than If/Else. If/Else is for choosing values; lazy switches are for choosing branches.
When it's the right tool
- Switching between two prompts or two model configs from a single toggle.
- Routing a value to a different consumer based on a comparison.
- Any "if this, use that, otherwise use the other" situation where both sides already exist in your graph.
If your condition comes from a node that can produce None, remember the rule: an unwired if_false passes None through, and downstream optional inputs will read it as "not connected." Sometimes that's exactly the graceful behavior you want.
Installing
cd ComfyUI/custom_nodes
git clone https://github.com/jetthuangai/NH-Nodes.git
cd NH-Nodes
pip install -r requirements.txt
Or install NH-Nodes via ComfyUI Manager and restart. No models, no downloads - pure graph logic.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| condition | BOOLEAN | true | — |
| if_true | * | — | |
| if_false | * | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| result | * | — |
| condition_out | BOOLEAN | — |