Number Compare
Compare numbers, get a boolean
- a
- b
- BOOLEAN
Conditional workflows in ComfyUI all boil down to one moment: you need a boolean that says "is this value bigger than that one?" - and then you feed that boolean into a switch to change behavior. Number Compare is the node for that exact moment. Feed it two numbers, pick a comparison, and out pops a BOOLEAN you can wire straight into an Input Switch, an Output Switch, or any node with a boolean toggle.
What it is
Inputs:
- a - left-hand operand (INT or FLOAT).
- b - right-hand operand (INT or FLOAT).
- comparison - the operator, chosen from a dropdown:
a == b,a != b,a < b,a > b,a <= b,a >= b. - negate - a toggle that inverts the result (default off).
Output: BOOLEAN - the result of the comparison.
The standout feature is the range check: the dropdown includes a <= b <= c, which checks whether b sits inside the range [a, c]. Selecting it reveals a third c input (the upper bound). That's the "is my step count between 20 and 40" or "is this resolution in the safe zone" check in one node instead of two compares and an AND gate.
Why you'd reach for it
It's the condition half of conditional workflows. Concrete patterns:
- Resolution guards. Compare a latent's width against a threshold; if it's too big, route to a downscale branch instead of feeding the sampler directly.
- Step/denoise gating. In a two-pass workflow, compare a value against a cutoff to decide whether to run the refinement pass.
- Range sanity. The
a <= b <= ccheck is perfect for "am I inside the valid range" logic before a node that errors outside it.
Combined with the pack's switches, you get a real if statement in graph form: Number Compare produces the condition, a switch executes the branch. It's the same primitive pattern you'd build in any of the logic-heavy node packs, but the built-in range check and the clean INT/FLOAT handling make it a bit less plumbing.
Installing it
Part of the Nifty Nodes pack:
cd ComfyUI/custom_nodes
git clone https://github.com/Stibo/comfyui-nifty-nodes
or search "Nifty Nodes" in ComfyUI Manager, then restart. No models or dependencies beyond the pack.
Gotchas
Float equality is float equality - a == b on two values that look the same can be false after math nodes round differently, so prefer <=/>= or a negated range check when comparing computed values. And negate is there because sometimes the inverted condition reads better than hunting for the opposite operator; wire it carefully, because an inverted range check is a classic silent bug. Also note the pack targets ComfyUI's newer V3 API - update ComfyUI if the node doesn't show up after install.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| a | INT,FLOAT | Left-hand operand. | |
| b | INT,FLOAT | Right-hand operand. | |
| comparison | COMBO | Comparison operator to apply. 'a <= b <= c' checks if b is within the range [a, c]. | |
| negate | BOOLEAN | false | Invert the result — True becomes False and vice versa. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| BOOLEAN | BOOLEAN | — |