Get Length
Check how many items are actually in your list or string
- ANY
- length
A small node that answers a question you'll ask constantly once you're building anything with PYLISTs or Lists in this pack: how many items is that actually holding? Get Length runs Python's len() on whatever you connect and displays the result right on the node - no separate preview node required.
How it works
There's nothing clever here by design - connect any value that supports Python's len(), and you get an INT back. That covers PYLISTs, ComfyUI Lists, strings (character count), and anything else in your graph that implements __len__. It doesn't work on scalars like a plain INT or FLOAT, for the same reason len(5) fails in plain Python: a single number doesn't have a length. The node is marked as an output node in its schema, which is why the result shows directly on the node itself in the graph - you don't have to route it into a text display node just to see the number.
The practical use is almost always a sanity check mid-build: you split a string and want to confirm you got the item count you expected, you globbed a folder with List Dir and want to eyeball the match count before kicking off a long batch, or you merged two PYLISTs and want to confirm the combined size before feeding it into something expensive. It's cheap, it's instant, and dropping one in temporarily costs nothing.
The inputs and outputs that matter
ANY- the value to measure. Works with anything that supportslen():PYLISTs, Lists, strings, and similar container types.
One output, length, an INT - and because this node is an output node, that value is also displayed directly on the node in the graph, not just passed downstream.
How to install it
ComfyUI Manager: search "ComfyUI-List-Utils," install, restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/godmt/ComfyUI-List-Utils.git
Restart afterward. No dependencies, no models - len() is a built-in, this node just wraps it.
Common issues & troubleshooting
Node errors with something like "object of type 'int' has no len()." You've connected a scalar value rather than a container. This node only works on things Python can measure the size of - lists, strings, dicts, and similar - not single numbers or booleans. If you're trying to count something that isn't naturally a container, this isn't the right node for it.
Connected a ComfyUI List and got 1 back instead of the real item count. This can happen if what's actually flowing into the socket isn't the List itself but a single item from it - check the node feeding this one and confirm it's genuinely outputting a List (is_list: true in its schema) rather than something that's already been collapsed to one value.
Number looks right but you wanted to use it in a calculation, not just glance at it. The length output is a normal INT output too, not just a display - wire it anywhere an INT input is expected, like a loop-count field on another node or into Exec for further math.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| ANY | * | Value to pass to len(). Works with List, PyList, strings, and other values that support len(). |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| length | INT | The result of len(value). |