Nodes/ComfyUI 1hewNodes/Any Empty Int
ComfyUI Node

Any Empty Int

Turn 'is it empty' into a number you can do math with

By 1hew·Created about a year ago·Updated 8 days ago· 33
Any Empty Int
  • any
  • int
empty0
not_empty1

Any Empty Int (1hew_AnyEmptyInt) is the integer-flavored sibling of the pack's Any Empty Bool. Same idea - check whether an input of any type is empty - but instead of a boolean it outputs one of two integers you choose: the empty value when the input is empty, the not_empty value when it isn't. Defaults are 0 and 1 respectively.

Why would you want a number instead of a boolean? Because the downstream graph doesn't always have a boolean consumer. Loops, index math, counters, and a lot of arithmetic nodes want an INT. And sometimes you want empty to map to something meaningful - a "no selection" case should become -1 or skip-index, not just "false."

How it works

Identical emptiness rules to its bool sibling, so the behavior is predictable across the pair:

  • None, blank/whitespace string, False, 0 → empty.
  • Zero-sized or all-zero tensor/array → empty.
  • Empty list/dict, or a list whose items are all empty → empty.

Then it picks empty or not_empty accordingly and outputs that integer. Both knobs have generous ranges (±999,999), so you can map empty to any sentinel you like.

Inputs and outputs

  • any (optional, any type) - the thing being checked.
  • empty - the INT to emit when empty, default 0.
  • not_empty - the INT to emit when not, default 1.
  • int - whichever of the two was selected.

Installing it

It's part of the 1hewNodes pack:

cd ComfyUI/custom_nodes
git clone https://github.com/1hew/ComfyUI-1hewNodes

or via ComfyUI Manager ("1hewNodes"), then restart.

Where it fits

The classic setup: a detection node yields a mask that may be all zeros, and you want a per-image "is there a subject?" as a number you can feed into a loop or a math node. Map empty→0, not_empty→1, and suddenly "how many frames had a subject" is a sum away. It also plays well with the pack's Int Number Compare - chain Any Empty Int into a > 0 comparison and you've built a not-empty gate that outputs a boolean again, with the semantics spelled out as integers instead of magic.

The one thing to remember: like its sibling, it treats 0 and False as empty. If a legitimately-zero integer is a real value in your pipeline, don't route through this node. Otherwise it's the pack's tidy answer to "I need a number, not a yes/no."

Category1hewNodes/logic

Inputs (3)

NameTypeDefaultDescription
emptyINT0-999999–999999
not_emptyINT1-999999–999999
anyopt*

Outputs (1)

NameTypeDescription
intINT