length
Length — the node that tells you how big your list actually is
- list
- length
length takes a LIST and returns how many items are in it, as an integer. That's it - the whole node. It's also one of the most useful in the pack, because half of list-related bugs come from not knowing the size of the thing you're iterating over. Every time you're about to index, slice, or guard a list, length is the number you want next to you.
How it works
It's a one-line wrapper:
return (len(list),)
len() counts the top-level items. Nested lists count as one item each - a list of three pairs has length 3, not 6. An empty list returns 0, never a negative number and never an error. The output is an INT named length, which feeds straight into comparisons (<=, >=, ==) from the same pack, or into if/else for size-based routing.
Where you'd use it
- Bounds checking. "Is this list big enough to safely
get itemat index 2?" Comparelengthagainst your index before you reach in. - Batch sizes. Know how many frames, prompts, or seeds you're about to process - and warn or skip if it's zero.
- Empty-list guards. The pack's
allreturnsTrueon an empty list andanyreturnsFalse; when you want the fact of emptiness rather than a truthiness quirk,length == 0is the unambiguous check. - Progress logic. If you're consuming a list,
lengthon the remainder tells you how much work is left.
Installing
It's in the "Basic data handling" pack by StableLlama. ComfyUI Manager: search "Basic data handling", install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
Restart ComfyUI. Zero dependencies, no models - pure Python wrappers, and one of the safest, most boring installs in the ecosystem.
Gotchas worth knowing
- It counts top-level items only - nesting is not flattened.
- Empty list →
0, always. Pair it with== 0(not!) if you're writing the classic "skip when nothing to do" gate. - It works on the pack's LIST type, not a native ComfyUI data list. If you're holding a data list, convert it to LIST first - the sizes aren't interchangeable concepts here.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| list | LIST | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| length | INT | — |