Logic Gate
AND, OR, NOT, XOR — actual boolean logic on the canvas
- result
ComfyUI has a real branching problem: you end up with half a dozen conditions - "is the batch big enough," "is the seed even," "did the filter return anything" - and you want to combine them before deciding which way the workflow goes. Logic Gate is the tiny node that does the combining. Two booleans in, AND / OR / NOT / XOR, one boolean out. It's the difference between "condition" and "conditions."
It's part of DebugPadawan's ComfyUI Essentials, a small MIT-licensed utility pack. Alongside its sibling Conditional String, it's the pack's answer to the ecosystem's switch-node sprawl - sometimes you just need a boolean, not a router.
How it works
Plain Python boolean operations under the hood:
- AND - true only if both inputs are true.
- OR - true if either is true.
- NOT (A) - inverts input
aonly. Inputbis ignored in this mode. - XOR - true if the inputs differ (implemented as
a != b).
One output: result, a BOOLEAN. Wire it into Conditional String for text switching, or into any switch/gate node that branches on a boolean.
The inputs that matter
- a - first boolean, default true.
- b - second boolean, default false.
- operation - the dropdown.
Install
Standard custom-node fare:
cd ComfyUI/custom_nodes
git clone https://github.com/DebugPadawan/DebugPadawans-ComfyUI-Essentials.git
Restart ComfyUI, or install via ComfyUI Manager by searching "DebugPadawan". requirements.txt lists numpy, torch, and opencv-python - numpy and torch already ship with ComfyUI and the shipped code never imports cv2, so no heavy downloads, no model files, no API keys.
Where people get burned
- NOT ignores
b. It'sNOT (A)by design - wiring anything intobis wasted work. If you want "NOT b," swap which input you calla. - Booleans must be real booleans. Feed it a string
"true"and this node won't behave - the truthiness of a non-empty string isTruein Python, which is a quiet lie. Convert strings to booleans first (the pack has a String to Boolean node). - XOR is "they differ," which is a neat mental shortcut: it's true exactly when the two conditions disagree. Great for toggle-style logic, occasionally surprising if you expected something else.
A clean pattern: gate a whole prompt-switch on "batch is non-empty AND seed is even" by chaining List Info's count comparison into a, a seed check into b, and feeding the result to Conditional String.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| a | BOOLEAN | true | — |
| b | BOOLEAN | false | — |
| operation | COMBO | 4 options: AND, OR, NOT (A), XOR |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| result | BOOLEAN | — |