QH: Bool Binary Operation
Real boolean logic for ComfyUI's gates and switches
- Result
Sooner or later your ComfyUI workflow becomes conditional logic. "Only run the face fixer if a face was found." "Use the high-CFG branch when the seed starts with a 3." At that point you need booleans to combine into decisions, and "QH: Bool Binary Operation" is the node that does the combining. It's a full set of binary logic operations - And, Or, Xor, Nand, Nor, Xnor, Eq, Neq - on two boolean inputs, with one boolean out.
ComfyUI's core is strangely thin here. It gives you booleans and a handful of control-flow nodes, but for anything past "if this then that," you end up stacking a Switch or a gate and juggling outputs yourself. This node gives you the actual truth table. It's the kind of utility that's obvious in hindsight and easy to underrate until you need to express "both of these conditions and not that one."
How it works
Two booleans in, one operation selected from a dropdown, one boolean out. The dropdown is an enum with eight choices, and they map directly onto the classic logic functions:
- And / Or / Xor / Nand / Nor / Xnor - the standard truth-table set, all implemented as one-liners in the source.
- Eq - true when
aequalsb; useful for "are these two conditions the same state." - Neq - true when they differ; a nice way to spot that two sources disagree.
Internally it's a tiny lookup table: each operation name maps to a Python lambda over the two booleans, and the node just calls it and returns the result. Nothing fancy, nothing stateful - which is exactly what you want from a pure logic node. It recomputes every execution, so changing a, b, or op re-evaluates instantly.
Inputs and outputs
op- the dropdown: Nor, Xor, Nand, And, Xnor, Or, Eq, Neq.a- BOOLEANb- BOOLEANResult- the output, a BOOLEAN
The practical wiring pattern: get your booleans from whatever's producing them (a compare node, a node that reports a condition, a manually toggled boolean) and feed the result into a Switch or a control-flow node that routes on it. If you find yourself chaining boolean outputs by hand, this is the node that lets you compress two conditions into one wire.
Installing it
Same trivial install as the rest of the pack - numpy only, no models to fetch:
- ComfyUI Manager - search "ComfyUI-QaisHelper" and Install.
- Manual -
cd ComfyUI/custom_nodes && git clone https://github.com/QaisMalkawi/ComfyUI-QaisHelper, then restart.
Everything lands under "Qais Helper/Boolean Operations" with the "QH:" prefix.
Gotchas
Two small ones. First, remember that Nand and Nor are the negated versions - Nand is "not (a and b)," which trips up people expecting a single "not both" without the inversion semantics. Second, like everything in this pack, it's pure plumbing: it won't validate that your logic makes sense, and a boolean in means a boolean out. If you wire a non-boolean into a or b and get weird routing downstream, check your inputs rather than the node. It's also worth keeping the mental note from the ecosystem playbook: boolean spaghetti is still spaghetti, so use this to collapse conditions you've already decided on, not to discover new ones.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| op | COMBO | 8 options: Nor, Xor, Nand, And, Xnor, Or, +2 | |
| a | BOOLEAN | — | |
| b | BOOLEAN | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| Result | BOOLEAN | — |