ComfyUI Node

XOR

The 'exactly one' gate for toggle logic

By danipisca07·Created 6 months ago·Updated 6 months ago· 0
XOR
    • BOOLEAN
    afalse
    bfalse

    XOR is "exclusive OR," and the word exclusive is the whole trick. Plain OR returns True when at least one input is true; XOR returns True only when exactly one is. Two true inputs give you False, which is the one behavior that surprises people and the one reason this node exists separately from OR.

    When you'd actually use it

    XOR is the toggle gate. The classic mental model: it flips its output whenever one of its inputs changes - true with (true, false), false with (true, true), true again with (false, true), and false with (false, false). That "change one thing and the answer flips" property is why XOR is the basis of toggles and switches in electronics, and in a workflow it shows up whenever you want "these two conditions can't both be the deciding factor."

    Concretely: say you have two alternate routes into a branch and you want to treat "both available" the same as "neither available" - proceed only when the situation is unambiguous. XOR gives you True for exactly the unambiguous cases. It's also the natural way to express "make the branch behave differently based on whether exactly one of two flags is set," which is fiddly to build with AND/OR/NOT alone.

    The honest take: XOR is the gate you'll reach for least of all five. OR, AND, and NOT carry 95% of real workflows. But when a "both is the same as neither" condition shows up, you'll be glad it's a single node instead of a small graph of inversions.

    How it works

    Python's a ^ b on booleans - two booleans in, one boolean out, no dependencies. The author's description nails it: "Returns True if exactly one of the two inputs is True." It lives in the SimpleLogics/Logic category next to OR, AND, NOT, NAND, and NOR.

    The inputs that matter

    Both are required BOOLEAN inputs, both default to False:

    • a - first boolean
    • b - second boolean

    One BOOLEAN output, wired like any other gate - typically into a switch's condition socket.

    Installing it

    Standard for the pack: danipisca07/ComfyUI-SimpleLogics is a small pure-Python pack with no requirements.txt and nothing to download. Install from ComfyUI Manager (search "SimpleLogics") or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/danipisca07/ComfyUI-SimpleLogics
    

    Restart ComfyUI and you're set.

    Common issues

    XOR's only real footgun is conceptual - expecting it to behave like OR and being confused when two true inputs return false. If a workflow's routing looks wrong, check whether you meant exclusive or inclusive. And since this pack is a young single-commit repo that also registers an unrelated GeoCalib camera node the README never mentions, don't be surprised by the extra node - ignore it. Beyond that, a two-input boolean gate is about as bulletproof as nodes get.

    CategorySimpleLogics/Logic

    Inputs (2)

    NameTypeDefaultDescription
    aBOOLEANfalse
    bBOOLEANfalse

    Outputs (1)

    NameTypeDescription
    BOOLEANBOOLEAN