Nodes/JNComfy/Boolean Operation
ComfyUI Node

Boolean Operation

AND/OR/XOR/NOT on any two wires in your graph

By jn-jairo·Created 2 years ago·Updated 2 years ago· 5
Boolean Operation
  • a
  • b
  • *
operation

This is boolean logic as a node: give it one or two values and an operation, get a result. It's part of a small cluster in JNComfy (jn-jairo/jn_comfyui) - alongside JN_MathOperation and JN_LogicOperation - that exists so you don't have to bail out to a Python-exec node every time you need a bit of actual logic in a graph that's otherwise all data pipes.

Why you'd want this in a graph

ComfyUI graphs aren't naturally great at conditionals - there's no built-in "if this AND that" node, so anyone building anything beyond a straight-line pipeline ends up either hand-rolling logic in a custom node or reaching for a general utility pack. rgthree-comfy's Power Puter, which lets you write python-like expressions mid-graph, is the well-known version of this idea; JN_BooleanOperation is the narrower, purpose-built version - one operation, two inputs, one output, no expression language to learn.

How it works

a is required, b is optional (some operations don't need it). Pick an operation from the enum - a and b, a or b, a xor b, not a - and it evaluates against whatever you've wired in. Both a and b are typed *, meaning this node accepts any value at all - a BOOLEAN, sure, but really anything Python's bool() can evaluate, thanks to JNComfy's patch that finishes wiring up ComfyUI's generic wildcard type.

The inputs and outputs that matter

  • a (any type) - required, your first operand.
  • operation - pick from a and b, a or b, a xor b, not a.
  • b (any type, optional) - your second operand. Leave it disconnected for not a; it's not used there.

Output is a single *-typed value - the result of the operation, typed generically so it can feed straight into whatever downstream node expects a boolean-ish value, including another JN_BooleanOperation if you're chaining logic.

How to install it

Via ComfyUI Manager: search "JNComfy", install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/jn-jairo/jn_comfyui

then restart. Fair warning: this is a niche, single-author pack - no meaningful community discussion of it that we could find anywhere, and it's not in our knowledge base either. If you get stuck, the source is short enough to just read.

Common issues & troubleshooting

"Why not just wire a BOOLEAN?" You can, but the point of the * typing is that you don't have to convert everything to BOOLEAN first - you can hand it whatever value you're already carrying (an INT, a STRING, an output from another node) and let Python's own truthiness rules decide. That's a convenience, but it also means a value you expect to be truthy might not be - an empty string or a zero will evaluate as false even if it "looks" like data to you.

Result feeds into something that expects a real BOOLEAN and it complains. Because the output is typed * rather than BOOLEAN, some strict downstream nodes may reject the connection outright depending on how ComfyUI's type-checking is configured for that node. If that happens, route the result through JN_LogicOperation or a plain boolean conversion node first.

You need more than AND/OR/XOR/NOT. This node is deliberately narrow - for comparisons like equals/greater-than, that's a different node in the same cluster: JN_LogicOperation.

CategoryJN/Primitive/Process

Inputs (3)

NameTypeDefaultDescription
a*
operationCOMBO4 options: a and b, a or b, a xor b, not a
bopt*

Outputs (1)

NameTypeDescription
**