ComfyUI Node

List Length

How long is that list? Ask the node

By ZXL-Xinram·Created about a year ago·Updated 9 months ago· 4
List Length
  • int_list
  • list_length

Sometimes the most useful number in a graph is a simple count. How many items are in this list - because that's how many iterations my loop needs, or how many frames I should request, or whether I even have enough entries to proceed. List Length takes any list on its int_list input and returns its size as an INT.

That's the entire job. One input, one output, no options to misconfigure.

How it works

The input is declared with INPUT_IS_LIST, so ComfyUI hands it the whole list rather than trying to unpack it. The node returns len(list) - or 0 for an empty one. Nothing else happens, which is the entire appeal: it's a leaf node you drop into a graph to make batch sizes visible and usable.

Inputs and outputs

  • int_list - the input. Despite the name it's a wildcard (*), so any list-type output from another node will connect, not just int lists.
  • list_length - the count as an INT.

Install

Standard pack install - ComfyUI Manager (search "ComfyUI-AutoFlow") or:

cd ComfyUI/custom_nodes
git clone https://github.com/ZXL-Xinram/ComfyUI-AutoFlow

Restart after. No dependencies beyond Python's len.

Where people get burned

  • Feeding a non-list value. Because the input is a wildcard, you can connect a plain INT to it - and ComfyUI will hand the node a scalar, which it then treats as a one-element thing. You'll get 1 where you expected a real count. Only feed it list outputs.
  • Expecting more than a count. This node answers "how many," not "which one" (that's List to Int Extractor, its sibling in the same pack) and not "what are the values." Wire the original list onward if you need the data.

It's a two-line node, and in a utility pack that's fine. Use it to drive loop counts or to sanity-check that a list-producing node actually produced anything before you burn GPU time on an empty batch.

CategoryAutoFlow/Utilities/Converters

Inputs (1)

NameTypeDefaultDescription
int_list*

Outputs (1)

NameTypeDescription
list_lengthINT