easy lengthAnything
Count how many items are on a wire
- any
- length
Tiny node, genuinely useful when you need it: hand it anything with a count - a batch of images, a list, a string - and it tells you how many. The output is a single integer. That's the whole node, and in a workflow that loops or batches, knowing the count is often the missing piece that lets the rest of the logic work.
The classic use is driving a loop. You've got a batch of images from somewhere and you want to process each one; a for-loop needs to know how many iterations to run, and easy lengthAnything is how you get that number without hard-coding it. Feed the batch in, get the count, wire the count into the loop's iteration limit. Now the graph adapts to however many images actually arrived instead of assuming a fixed number.
How it works
It measures the length of whatever you feed it and returns it as an INT. For a batched tensor (a stack of images or latents) that's the batch dimension - the number of items. For a list it's the item count; for a string, the character count. Because the input is the ComfyUI wildcard (*), it takes any type; what "length" means just follows the natural sense of whatever you plugged in.
The inputs and outputs that matter
any(wildcard) - the thing to measure.length(output, INT) - the count.
Wire the length into a loop's count, a range node's stop value, an index calculation, or anywhere a downstream node needs to know "how many." It pairs naturally with the for-loop and index-switch nodes in the same Logic family.
How to install it
Part of ComfyUI-Easy-Use. ComfyUI Manager: search ComfyUI-Easy-Use, install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/yolain/ComfyUI-Easy-Use
then install.bat (Windows) or pip install -r ComfyUI-Easy-Use/requirements.txt, and restart. No models.
Common issues & troubleshooting
Batch vs. list gives different numbers than you expect. ComfyUI distinguishes a batch (one tensor with N items stacked on the batch dimension) from a list (N separate objects processed one at a time). lengthAnything reports the length of whatever it's actually handed. If the number looks wrong, check whether the thing upstream is a batch or a list - you may need to convert first (Easy-Use has nodes for that) so you're counting the dimension you meant.
Counting a string counts characters. Feed it a text string and you get the character count, not a word or line count. That's usually not what people expect from a prompt - if you wanted lines or items, split the text into a list first.
Length of 1 for a single item. A lone image is a batch of one, so you get 1 - correct, but occasionally surprising if you were expecting the node to fail on a non-collection. It won't; a single item has length 1.
Nothing connected. With no input it has nothing to measure. Make sure any is actually wired.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| any | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| length | INT | — |