ComfyUI Node

Nand

The boolean gate everyone forgets (until they need it)

By marco-zanella·Created about a year ago·Updated about a year ago· 0
Nand
    • nand
    firsttrue
    secondtrue

    Nand is "not-and": it returns true unless both inputs are true. If you've never used it in a ComfyUI workflow, you're in good company - most people reach for And, Or, and Not and call it a day. But Nand is the inverse logic you want when a condition should hold for "everything except this specific combination." It's And's strictness, flipped on its head.

    It's from marco-zanella's ComfyUI-BooleanExpression pack, a dependency-free logic collection that ships the full gate set precisely so you don't have to build these out of And-plus-Not. Nand is the classic "not (first and second)" - and since it's a universal gate in digital logic, you can build every other boolean operation out of it, though you won't need to.

    How it works

    Two required inputs, both BOOLEAN and both defaulting to true:

    • first - the first boolean value
    • second - the second boolean value

    Output is nand, a BOOLEAN: not (first and second). One line of Python. The truth table: true, true, true, false - everything passes except the case where both inputs are true.

    Where it actually helps in a workflow: "do the normal thing unless both of these are true." Say you want the fast path unless the resolution is high and the batch is large - that's an And for the slow path and a Nand for the fast one. It's the "everything but the special case" condition, expressed in a single node instead of an And feeding a Not.

    Installing it

    No models, no dependencies, pure Python - the pack's requirements.txt is empty. ComfyUI Manager, search ComfyUI-BooleanExpression, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/marco-zanella/ComfyUI-BooleanExpression.git
    

    Restart ComfyUI, and it's under Boolean Expressions.

    Gotchas

    • Both inputs default to true - and since not (true and true) is false, a fresh Nand node reads false until you wire real values in. The opposite of the And/Or defaults. "Why is nothing happening" strikes again.
    • Don't reach for it if you want And. Nand is the inverse. If your logic starts misbehaving, double-check you grabbed Nand and not And - the names are one letter apart and the behavior is entirely different.
    • It's still just a boolean value. Chain it into a Conditional Branch and both input chains upstream still compute; Nand doesn't skip anything. Trivial for booleans.
    • If you're juggling several gates, Binary Expression in the same pack folds and/or/xor/nand/nor into one dropdown - nice for tinkering, though the dedicated node reads better in a shared workflow.

    Nand is a niche gate, and you could live your whole ComfyUI life without it. But the moment you need "everything except this specific combination," it's the difference between one clear node and a stack of And-plus-Not you'll have to decode later.

    CategoryBoolean Expressions

    Inputs (2)

    NameTypeDefaultDescription
    firstBOOLEANtrueThe first boolean value.
    secondBOOLEANtrueThe second boolean value.

    Outputs (1)

    NameTypeDescription
    nandBOOLEAN