Compare
How your ComfyUI workflow learns to make decisions
- a
- b
- BOOLEAN
Every useful "if" in a ComfyUI workflow starts with a comparison, and this is the node that does them. Feed it two values, pick an operator, and it hands you a clean BOOLEAN - which is exactly what the pack's If node wants to see on its ANY input. Without this node, your graph is stuck running the same way every time; with it, the graph can look at what it just produced and react.
The mechanism is boring in the best way. Inside the pack there's a plain dictionary of six lambdas, one per operator:
"a == b": lambda a, b: a == b,
"a != b": lambda a, b: a != b,
"a < b": lambda a, b: a < b,
"a > b": lambda a, b: a > b,
"a <= b": lambda a, b: a <= b,
"a >= b": lambda a, b: a >= b,
The node looks up your chosen comparison and runs it. No cleverness, no ambiguity - just Python comparison semantics.
The three inputs
- a - first value, wildcard (
*), default0. - b - second value, wildcard (
*), default0. - comparison - a dropdown with the six operators above, defaulting to
a == b.
Both a and b are wildcards, so you can compare integers, floats, strings, even booleans. The output is a single BOOLEAN.
Where people get burned
The wildcard inputs are a convenience and a trap. Python comparison semantics apply, which means comparing different types blows up: 3 < "7" raises a TypeError in 3.x, and you'll get a red node instead of a false. Compare like with like - numbers to numbers, strings to strings. Also, a and b default to 0, so if you wire nothing in and just toggle the operator you're comparing zero to zero, which is a truthy True for == and a lie for <.
And don't point it at images or latents. a < b on two tensors doesn't give you "is this image darker" - it gives you an elementwise tensor mess or a crash. This node is for scalars and text, full stop.
How you'd use it
The canonical pattern is the portrait-vs-landscape problem that shows up in ComfyUI help threads constantly. You read an image's dimensions, feed height and width into a and b, pick a > b, and the resulting BOOLEAN goes into the If node's ANY to pick between a portrait resize path and a landscape one. Same shape works for CFG thresholds, batch-size decisions, or stepping a counter and comparing it to a limit.
The output type is BOOLEAN, so it plugs straight into anything that wants a boolean - the pack's If ANY return A else B-🔬, or core ComfyUI's Logic/If. Note ComfyUI itself ships a basic Compare node these days; this one is functionally the same, just 🔬-branded.
Install
Standard for this pack. ComfyUI Manager, search ComfyUI-Logic, or:
cd ComfyUI/custom_nodes
git clone https://github.com/theUpsider/ComfyUI-Logic
Restart ComfyUI. Zero dependencies, zero model downloads - the pack is a single Python file, so it installs cleanly and won't drag anything else into your dependency tree. It's also unmaintained per the repo header, which matters less here because this node is finished code that doesn't need updates. When you're debugging a comparison that's feeding the wrong branch, remember the troubleshooting rule from the community playbook: change one variable at a time, fixed seed, and read the output before you blame the operator.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| a | * | 0 | — |
| b | * | 0 | — |
| comparison | COMBO | a == b | 6 options: a == b, a != b, a < b, a > b, a <= b, a >= b |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| BOOLEAN | BOOLEAN | — |