ComfyUI Node

Compare 🦾

Compare anything to anything, get a yes or no

By beyondprompting·Created 9 months ago·Updated 7 months ago· 0
Compare 🦾
  • a
  • b
  • BOOLEAN
comparisona == b

Compare is the "should I even run this?" node. It takes two values, applies one of six comparison operators, and spits out a boolean you can feed straight into a switch, a conditional, or a bypass gate. It's the difference between a workflow that blindly runs every branch and one that makes decisions.

It's a port of the classic ComfyUI-Logic extension's Compare node, carried over (with a -beyond_nodes suffix) into this pack. If you've used logic nodes in other tools, nothing here will surprise you.

How it works

The two inputs are any-typed wildcards - you can compare ints, floats, or strings. The comparison dropdown holds the six operators: a == b, a != b, a < b, a > b, a <= b, a >= b. Under the hood it's a lookup table of Python lambdas; the chosen operator is evaluated and the boolean result comes out the single output.

The any-typing is enforced by a proxy class that claims to match everything, which is why you can drag practically anything onto the sockets. That's also the trap: it will happily "compare" two images and tell you the tensors aren't equal - a correct but useless answer. Keep it to scalars and strings and it behaves.

The inputs that matter

  • a (required, any type) - left side of the comparison.
  • b (required, any type) - right side.
  • comparison (required, default a == b) - which of the six operators to apply.

Output: BOOLEAN - true or false.

Install

Part of ComfyUI-Beyond_nodes, the whole pack installs at once. ComfyUI Manager → search "Beyond_nodes" → install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/beyondprompting/ComfyUI-Beyond_nodes

Restart ComfyUI. No extra pip dependencies.

Common issues

  • It compares strings differently than numbers. "10" < "9" is true because string comparison is alphabetical. If you're comparing numbers, feed them from Int/Float nodes, not text.
  • The output never changes. You've probably wired the same node into both a and b. Check the actual connections - easy to do on wildcard sockets.
  • I want to compare a number to a threshold I can tweak. That's this node's bread and butter: feed a dynamic value into a, hardcode b as a widget, and drive a switch with the result.

Where it shines: gating a high-res pass on image dimensions, only running a LoRA when a setting is above a threshold, or building an if/then branch without writing a single line of code.

CategoryLogic

Inputs (3)

NameTypeDefaultDescription
a*0
b*0
comparisonCOMBOa == b6 options: a == b, a != b, a < b, a > b, a <= b, a >= b

Outputs (1)

NameTypeDescription
BOOLEANBOOLEAN