ComfyUI Node

and (generic)

An AND gate that doesn't care what you feed it

By StableLlama·Created about a year ago·Updated 4 days ago· 48
and (generic)
  • item_0
  • BOOLEAN
invertfalse

Most boolean nodes in ComfyUI demand actual BOOLEAN wires and pout if you give them anything else. This one shrugs, takes whatever you have, and applies Python's own truthiness rules to it. That's the whole pitch of "and (generic)" from the Basic data handling pack: an AND gate with an attitude - and honestly, with some utility.

What it does

It returns True only if every connected input is "truthy," and False the moment any one of them isn't. The twist is what "truthy" means. The node evaluates values the way Python does: the number 0, an empty string "", an empty list, and False are all falsy. The string "0"? Truthy - it's a non-empty string. The number 5? Truthy. This is the same rule that makes if "yes" work in Python, and it means you can wire this node's inputs straight onto all sorts of non-boolean outputs without casting first.

The invert trick

There's a required invert checkbox (default off). Tick it and the result flips, turning the whole thing into an NAND gate. It's a one-click way to get "not all of these are true" without bolting a separate not node onto the output.

Inputs and outputs

  • invert - BOOLEAN, default false. Flip to get NAND behavior.
  • item_0 - a wildcard * input, default "True", and the node takes a dynamic number of these. Add more item_N inputs from the node's UI (the pack's dynamic-input support) and wire in as many values as you need. Note the default: leave item_0 unwired and it counts as True, which is exactly what you want when you're AND-ing just to gate one branch.
  • Output - a single BOOLEAN, the AND (or NAND) of everything.

Install

Comes with the Basic data handling pack. Manager → search "Basic data handling" → install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling

then restart ComfyUI. No dependencies, no model downloads - the pack is plain Python builtins.

Where people get burned

They forget that an empty string or 0 is falsy, so a workflow that "should" return True comes back False because one input arrived as an empty text field. If that bites you, check what's actually on each wire before assuming the node is broken. And remember invert flips the whole result - the one time you tick it "to see what it does" and leave it ticked is the classic self-inflicted bug.

CategoryBasic/BOOLEAN

Inputs (2)

NameTypeDefaultDescription
invertBOOLEANfalse
item_0opt*True

Outputs (1)

NameTypeDescription
BOOLEANBOOLEAN