Nodes/ComfyUI-Basic-Math/Boolean Logic | Basic
ComfyUI Node

Boolean Logic | Basic

Real AND/OR/XOR logic for your workflow

By akatz-ai·Created about a year ago·Updated 11 months ago· 16
Boolean Logic | Basic
    • BOOLEAN
    a
    b
    operation

    Boolean logic is where ComfyUI workflows learn to make decisions. Once you've got comparisons outputting true/false - say, "is this image wider than it is tall?" or "is this step count over 20?" - you eventually want to combine those answers. That's exactly what BooleanLogic ("Boolean Logic | Basic") does: it takes two booleans, applies one of six logic operations, and hands you back a single true/false you can route into a switch or a conditional.

    It's a small node with a simple mechanism. Feed a and b (both BOOLEAN sockets) and pick an operation: AND, OR, XOR, NAND, NOR, XNOR. The output is a single BOOLEAN. There's nothing hidden here - it's the truth tables you learned in school, computed live in Python.

    The inputs that matter

    • a, b - the two conditions you're combining. Wire these up from comparison nodes (this same pack's NumberComparison, FloatComparison, or IntegerComparison are the natural sources).
    • operation - the one dropdown you'll actually touch. AND and OR will cover 90% of real use; XOR is "exactly one of these is true," and the negated forms (NAND, NOR, XNOR) exist so you don't need to chain a NOT node afterward.

    Output BOOLEAN feeds anything that wants a true/false - switches, bypass toggles, conditional samplers.

    Why you'd actually reach for it

    The classic use is guarding a workflow path. Say you want to apply an upscale pass only when two conditions hold: the image is large enough and you toggled a boolean widget for "upscale enabled." Two comparisons + one AND, and the result can drive a node that chooses between the upscale branch and the pass-through branch. Without this node you'd be stacking switches or writing the logic into a text node. It's also the honest replacement for trying to fake conditionals with min/max math, which gets unreadable fast.

    One thing I like about this pack specifically: the Boolean subcategory also ships a BooleanInput (a plain true/false constant) and BooleanUnary (NOT/IDENTITY), so you've got the whole boolean toolkit in one menu instead of hunting across five packs for the pieces.

    Installing it

    This is one of 23 nodes in the akatz-ai Basic Math pack, and the install is the same for all of them - pure Python standard library, zero dependencies, no models:

    cd ComfyUI/custom_nodes
    git clone https://github.com/akatz-ai/ComfyUI-Basic-Math
    

    Restart ComfyUI, then find it under Basic Math ➕ → Boolean. Or use ComfyUI Manager → Install Custom Nodes → search "ComfyUI-Basic-Math".

    The gotchas

    The node expects real booleans on both inputs. If you're feeding it a number from somewhere, convert it first with the pack's ToBool - otherwise the socket won't accept the wire. And don't hunt for it under a plain "Boolean Logic" name: this pack appends | Basic to every node title, so you'll see "Boolean Logic | Basic" in the search. Same node, the suffix is just this pack's way of avoiding collisions with the many other logic packs out there.

    CategoryBasic Math ➕/Boolean

    Inputs (3)

    NameTypeDefaultDescription
    aBOOLEAN
    bBOOLEAN
    operationCOMBO6 options: AND, OR, XOR, NAND, NOR, XNOR

    Outputs (1)

    NameTypeDescription
    BOOLEANBOOLEAN