ComfyUI Node

Boolean XOR

The 'exactly one of these, not both' gate

By Stibo·Created 5 months ago·Updated 2 months ago· 9
Boolean XOR
    • BOOLEAN
    a
    b

    Most of the time you want AND or OR. But there's one question neither answers: "is exactly one of these true, and not both?" That's XOR - exclusive OR - and it's the gate that turns up when two inputs are mutually exclusive and you want to detect the mismatch. Two booleans in, one boolean out, true only when they differ.

    When you'd actually use it

    In a ComfyUI workflow, XOR is the "these two things disagree" detector. Classic example: you have two ways a workflow can be configured - say an "use reference" toggle and a "use mask" toggle - and you want a warning or a branch when the user has flipped both on in a way that doesn't make sense. XOR returns true exactly when one is on and the other is off, so it makes a clean "these settings conflict" signal.

    It's also genuinely useful for toggle-flip detection in graphs that feed state around: if you've got a boolean that should switch meaning each run, XOR against a stored previous state gives you "it changed" - the poor man's edge detector. You won't use it every day, but on the day you need it, there's no stock ComfyUI node sitting there waiting.

    The node itself is bare-bones by design: two required boolean inputs a and b, one BOOLEAN output computed as a ^ b. No settings, nothing hidden.

    Pairing it with the rest of the pack

    Nifty Nodes' logic family covers the full set - AND, AND All, OR, OR Any, NOT, and this. If you find yourself reaching for XOR more than once in a workflow, you're probably overcomplicating something; once is fine, and this is the clean way to do it. All of it runs on the current comfy_api.latest v3 API, so it's Nodes 2.0-frontend friendly with no legacy shims.

    Install

    Ships in Nifty Nodes for ComfyUI. Manager: search "Nifty Nodes for ComfyUI" → Install → restart. Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Stibo/comfyui-nifty-nodes
    

    Restart ComfyUI. Pure Python, no models, no per-node dependencies. The pack is MIT-licensed and young (v2.1.0, mid-2026) - update it if a workflow doesn't recognize the node class.

    Gotchas

    The usual reminder: an XOR output is just a value. It won't stop a branch from executing on its own - wire it into a switch or bypass node, preferably a lazy one, if you want actual execution control. And remember XOR on booleans means "differ," not "one is true" - a user who reads the name as "either or" will be surprised that both-true returns false, which is exactly the behavior you want for a conflict detector.

    Categorynifty/logic

    Inputs (2)

    NameTypeDefaultDescription
    aBOOLEANFirst operand.
    bBOOLEANSecond operand.

    Outputs (1)

    NameTypeDescription
    BOOLEANBOOLEAN