ComfyUI Node

List Length

The one-line sanity check for list workflows

By M1kep·Created 3 years ago·Updated 2 years ago· 56
List Length
  • In
  • Length

You've built a workflow that iterates a list - ten seeds, six CFG values, a folder of reference images - and before you queue it you'd kill to know exactly how many items are in that list. List Length is the node that answers that, and it does it without drama: wire in any list, get an integer back.

It's the kind of node you don't think you need until the first time a batch ends early because your seed list had nine entries instead of ten. Then it lives in every workflow. In a ComfyUI graph where one node fans a list out across an entire batch, knowing the length of that list is the difference between a clean run and "why did I only get 9 images?"

How it works is a single line of Python: it returns len(In). Because the node declares itself list-aware (INPUT_IS_LIST = True), ComfyUI hands it whatever you connect as a list, even if you connected one lone value. That last bit matters: feed it a single integer and it treats that as a one-element list, so Length comes back as 1 - which is correct, but it tells you about the thing you connected, not about how many values you intended.

The only input is In, and it accepts anything (* type) - string lists, float lists from a Range node, image lists from Image List Loader, whatever. The only output is Length, an INT. Because it's a plain scalar (not a list itself), you can wire it straight into any integer input on another node, or use it to compare two lists: put both lists through their own List Length and check the numbers match before you Join them.

Where people get burned: this node can't count items inside a batch. If you hand it a single IMAGE tensor that happens to contain 4 images batched together, it says 1, because as far as list semantics are concerned there's one tensor. For a genuine "how many images are in this batch" you want the Sizes output from Join Image Lists instead.

Installing it is the same as every node in the pack - Comfy_KepListStuff has no dependencies beyond what ComfyUI already bundles, so there's no pip step and no model download:

cd ComfyUI/custom_nodes
git clone https://github.com/M1kep/Comfy_KepListStuff

Then restart ComfyUI. Or skip the terminal entirely: open ComfyUI Manager, search Comfy_KepListStuff, and hit install. You'll find List Length under the List Stuff category.

It's not flashy and it doesn't generate anything. But when a batch mysteriously comes up short, it's the first node you'll reach for.

CategoryList Stuff

Inputs (1)

NameTypeDefaultDescription
In*

Outputs (1)

NameTypeDescription
LengthINT