ComfyUI Node

If Any

The one-socket node that tells your graph whether you actually plugged something in

By FranckyB·Created 6 months ago·Updated a day ago· 13
If Any
  • value
  • bool

ComfyUI graphs are pipelines, and pipelines have no if. That's why a node called If Any exists: one wire in, a BOOLEAN out, answering "was there actually something on the other end of this?" - and you use that boolean to make the graph behave differently.

What it's for

Roughly 70% of any workflow is plumbing: nodes that touch no pixels and appear in no model page you've ever read. If Any (class IfAny) is the smallest useful citizen of that layer - no models, no tensors, no UI.

Reach for it when your graph has an optional branch. You sometimes have a mask, sometimes don't; sometimes a reference image, sometimes only a prompt. Keeping two copies of a workflow is how they drift apart. You can't type if into a ComfyUI graph, so you convert conditions into values - this node produces the value.

How it works

Two engine facts make it possible. First, ComfyUI's type system has one escape hatch - the wildcard type "*", which accepts a connection from anything, leaving the node responsible for making sense of what arrives. Second, an optional input you leave unwired is simply not passed to the function at all, so nodes read None as "nothing connected."

If Any declares one optional ("*") input and defaults its check() argument to None. Unwired in, False out. Wire something in and it coerces whatever it got: numbers are true unless they're 0; lists, tuples and dicts are true if non-empty; tensors (IMAGE, LATENT, MASK) are true if they hold more than zero elements, checked via numel() with size/shape fallbacks. Strings are another story - see below.

Inputs and output

One input, one output:

  • value - optional, any type, marked forceInput, which means it is always a socket and never becomes a widget. There is no box you can type into. Dropping the node bare gives you a permanent False that flips to True the moment something is wired in.
  • bool - a single BOOLEAN output. That's the payload.

Booleans are real inputs elsewhere, so this plugs into more than you'd expect. The natural partner in the same pack is Switch Any (Boolean), whose two branches are lazy - only the selected one is evaluated - with condition as a proper boolean input. You can also right-click any boolean widget, Convert widget to input, and drive it from If Any: save on Save Video+, enable on LTX Review, and so on. Same trick works on any pack that exposes booleans.

If Any is not lazy itself. Its input carries no lazy flag, so whatever branch you wire into it runs as normal, every time. It gates what happens downstream; it does not skip the work you connected to it. If your goal is genuinely pruning compute, you want a lazy switch (this pack's SwitchAny, or kjnodes' lazy switch), not this.

Where people get burned

The string branch is a whitelist, not Python truthiness. The stripped, lowercased text is compared for membership in exactly {1, true, yes, on}. So wiring a CLIP text encode into If Any to ask "is there a prompt?" returns False for "a photo of a cat" and True only if the text is literally yes, on, true or 1. The tooltip's "truthy connected values" line doesn't hold for strings. Use it on tensors and numbers; don't use it as a text-presence test.

Second: False is overloaded. It means unplugged, but it also means connected-but-empty - an empty tensor, an empty list, a 0. You can't tell those apart from the output, so keep both branches of whatever you're gating safe to run in the empty case.

Install

Search ComfyUI-FBnodes in ComfyUI Manager and install it, or do it by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/FranckyB/ComfyUI-FBnodes.git
pip install -r ComfyUI-FBnodes/requirements.txt

Restart ComfyUI completely afterwards, and hard-refresh the browser. The pack ships frontend JS (WEB_DIRECTORY = "./js") for its file browsers, crop UI and top-bar Remap Missing Models button, and a half-installed frontend is the usual "node's there but nothing works" report.

On dependencies: the README's Requirements section names only av (PyAV), but the shipped requirements.txt lists av and color-matcher, used only by VACE Stitcher's color matching. If Any needs neither - it's pure Python - but install from the requirements file rather than by assumption, since that's what the repo actually runs.

When I'd reach for it

If your workflow only ever has one shape, skip this node. The moment you catch yourself bypassing a group by hand to toggle between "with mask" and "without mask," you want the presence check: If Any into a lazy boolean switch, both configurations live in one graph, no manual flipping. Just remember it's a presence test, not a fallback - for "use the first of these five that isn't empty," that's rgthree's Any Switch, a different job.

CategoryFBnodes

Inputs (1)

NameTypeDefaultDescription
valueopt*Any optional input. Returns true for truthy values and false for empty, None, 0, or disconnected input.

Outputs (1)

NameTypeDescription
boolBOOLEAN