ComfyUI Node

Logic Gate

AND, OR, NOT, XOR — actual boolean logic on the canvas

By DebugPadawan·Created about a year ago·Updated 5 months ago· 2
Logic Gate
    • result
    atrue
    bfalse
    operation

    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 a only. Input b is 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's NOT (A) by design - wiring anything into b is wasted work. If you want "NOT b," swap which input you call a.
    • Booleans must be real booleans. Feed it a string "true" and this node won't behave - the truthiness of a non-empty string is True in 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.

    CategoryDebugPadawan/Logic

    Inputs (3)

    NameTypeDefaultDescription
    aBOOLEANtrue
    bBOOLEANfalse
    operationCOMBO4 options: AND, OR, NOT (A), XOR

    Outputs (1)

    NameTypeDescription
    resultBOOLEAN