Nodes/SDVN_Comfy_node/#️⃣ Boolean
ComfyUI Node

#️⃣ Boolean

Compare two values, get a true/false to gate your flow

By StableDiffusionVNΒ·Created 2 years agoΒ·Updated 29 days agoΒ· 118
#️⃣ Boolean
  • a
  • b
  • boolean
β—„logicβ–Ύβ–Ί

This node compares two values and spits out a BOOLEAN - true or false. On its own that sounds trivial, but it's the piece that makes conditional workflows possible: you use the boolean it produces to drive a Logic Switch, decide which branch runs, or filter a list. It's the "if" in an if-then you build out of nodes. The pack files it alongside the switch nodes for a reason - Boolean is usually the thing feeding one.

It handles both numeric comparisons and membership tests, which is more than you might expect from a comparison node.

How it works

You give it two values, a and b, and pick a comparison from the logic dropdown. It evaluates that comparison and outputs the result. The options cover the usual arithmetic set plus containment:

  • a = b, a != b - equal / not equal
  • a > b, a < b, a >= b, a <= b - the ordering comparisons, for numbers
  • a in b, a not in b - membership, e.g. is this substring inside that string, or is this item in that list

That in pair is what makes it handy for text: "does the filename contain 'cat'" is a = "cat", b = the filename, logic = a in b.

The inputs and outputs that matter

  • a and b (any type) - the two values to compare.
  • logic - which comparison to run, from the eight above.

The output is boolean - wire it into the pack's Logic Switch to pick a branch, into Filter List to keep matching items, or anywhere a true/false gate is needed.

How to install it

Comes with the SDVN pack. ComfyUI Manager, search SDVN_Comfy_node; or:

cd ComfyUI/custom_nodes
git clone https://github.com/StableDiffusionVN/SDVN_Comfy_node
pip install -r custom_nodes/SDVN_Comfy_node/requirements.txt

from the ComfyUI root, then restart. No models, no dependencies.

Common issues & troubleshooting

Type mismatch. Comparing a string to an int with > is asking for trouble - make sure a and b are the same kind of thing for ordering comparisons. If you're comparing numbers, feed actual numbers, not numeric strings, or a 4 > 10 can misbehave as text.

Which one is a, which is b. The comparisons aren't symmetric - a in b and b in a are different questions, and a > b flips if you swap them. Double-check the wiring matches the sentence you mean.

in semantics depend on the types. With strings, a in b is substring containment. With a list in b, it's "is a an element." That's usually what you want, but know which one you're doing.

The output looks right but the branch didn't switch. Boolean only produces the value - it doesn't act on it. You still need a Logic Switch (or similar) wired to that boolean for anything to actually branch. If nothing changed, check that downstream connection, not this node.

CategoryπŸ“‚ SDVN/πŸ’‘ Creative

Inputs (3)

NameTypeDefaultDescription
a*β€”
b*β€”
logicCOMBO8 options: a = b, a != b, a > b, a < b, a >= b, a <= b, +2

Outputs (1)

NameTypeDescription
booleanBOOLEANβ€”