view_GetLength
Count anything — lists, strings, dicts, batches — as an INT
- ANY
- length
view_GetLength takes any input on its ANY socket and gives you back its length as a plain INT. Feed it a list, a string, a dict, or an image batch, and out comes "how many things are in here." It's a tiny node with one job, and it's genuinely useful for two reasons: sanity checks and math.
Sanity checks first, because that's where it saves you the most time. "Is my prompt list actually 8 items or 80?" - wire it in, run, read the number. Did that loop produce the batch size you expected? Same trick. The debugging principle every ComfyUI regular learns is to check your assumptions one at a time, and this node is the cheapest possible way to check "is this collection the size I think it is" before feeding it into something that will fail loudly if it isn't.
Then the math. Because the output is a real INT, you can feed it into arithmetic or conditional nodes: loop a range up to the batch size, divide a budget across N items, or gate a switch on "list is empty." That's what makes it more than a display node - the length leaves the node as a value you can compute with.
How it works
The node calls len() on whatever arrives, for Python-native collections, or reads the batch/count dimension for tensors. An image with 4 frames returns 4; a string returns its character count; a list returns its element count. The single length output carries the result. There's no configuration - one input, one output.
The inputs and outputs that matter
ANY- the required input. Plug in a list, string, dict, tensor, whatever.length(INT) - the count.
How to install it
It ships with ComfyUI-Apt_Preset. Install the pack once via ComfyUI Manager (search "ComfyUI-Apt_Preset") or:
cd ComfyUI/custom_nodes
git clone https://github.com/cardenluo/ComfyUI-Apt_Preset
then run install.bat (Windows) or pip install -r requirements.txt, and restart ComfyUI. No model downloads.
Common issues & troubleshooting
The one mental trap: for images and latents, "length" means the batch/frame count, not the pixel count. An image that's 1024×1024 still returns 1 (one image in the batch) unless it's a batch of several. If you need dimensions, use view_GetShape instead - different question, different node. If you're feeding a string and the number looks too big or too small, remember it counts characters, including spaces; that's len("abc") == 3, not words.
One genuinely nice pairing: feed view_GetLength the output of view_combo and you get an instant count of your prompt schedule, which you can then feed into a loop or a math node to, say, split a video's frame budget evenly across prompts. Length becomes the input to other things, not just a fact you read.
Pack-level, the standing caveat: niche pack, Bilibili-based author, translated README. If the node won't load, the pack's dependencies weren't installed - the recurring community report is IMPORT FAILED, resolved by running install.bat and restarting ComfyUI.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| ANY | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| length | INT | — |