ComfyUI Node

Any Compare

A comparison node that doesn't care what you feed it

By wenchengxiang·Created 2 months ago·Updated 9 days ago· 3
Any Compare
  • a
  • b
  • boolean
◄comparisona == b►

Core ComfyUI's Compare node is picky: both sides have to be the same type, INT against INT, FLOAT against FLOAT. Fine for the 90% case. Any Compare is the version that doesn't care - its a and b inputs are the * wildcard type, so you can compare two integers, two strings, a seed against a step count, whatever you happen to have on hand. It's the compare node you reach for when the graph is getting conditional and you'd rather not keep every comparison typed and strict.

The three inputs are simple:

  • a and b - the two values, any type (both default to 0)
  • comparison - a dropdown with the six operators: a == b, a != b, a > b, a >= b, a < b, a <= b

The single output is boolean, and it wires into anything that takes a BOOLEAN: a switch, a gated branch, or a widget you've converted to an input so a sampler or VAE decode only runs when a condition is true.

How it works is the whole story: the comparison string maps straight onto a Python operator. a > b becomes lambda a, b: a > b and it just runs. No API, no state, no sneaky math - what you see is what executes.

Where it earns its keep is the "programming language with no keyboard" side of ComfyUI that the KB's node-plumbing notes cover: once you treat a workflow as a small program, comparisons are how you make decisions. Compare two seeds to detect a change. Compare a batch size against a threshold to route to different handling. Compare an audio or video frame count against a target so a conditional branch fires only when you've hit the mark.

Two gotchas worth knowing, because they're the price of the wildcard:

  • Both sides default to 0, not None. Leave b unconnected and you're comparing a against literal zero - it does not read as "unset." If you want "is b connected" logic, this isn't the node; use a switch family node instead.
  • No type checking, ever. Because the sockets are *, ComfyUI won't stop you wiring a string into a > b, and Python will throw a TypeError at run time rather than at connection time. The same goes for comparing things that don't compare cleanly - don't feed it two tensors and expect a scalar boolean out. Keep it to scalars and strings and you'll be fine.

Install is the same as the rest of the pack: ComfyUI Manager, search ComfyUI-Practical-Tools, install, restart. Or by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/wenchengxiang/ComfyUI-Practical-Tools

There's no requirements.txt and nothing to download - the only config file exists so the pack shows up in the Comfy Registry. If you hit a TypeError on a run, the cause is almost always a string or tensor sitting in a or b where the operator can't handle it; check what's actually connected before you blame the node.

CategoryPractical-Tools/utils

Inputs (3)

NameTypeDefaultDescription
aopt*0—
bopt*0—
comparisonoptCOMBOa == b6 options: a == b, a != b, a > b, a >= b, a < b, a <= b

Outputs (1)

NameTypeDescription
booleanBOOLEAN—