ComfyUI Node

List Count

How many things are in that list, anyway?

By TinyBeeman·Created about a year ago·Updated about a month ago· 1
List Count
    • Count
    string_list

    List Count does one thing: tells you how many items a list has. A three-line Python node that counts the entries in whatever list you feed it and returns the number as an INT. Simple enough to look pointless - until you're building loops and need to know how many iterations you're dealing with.

    Why you'd reach for it

    ComfyUI's list story is a mess of different packs each doing their own thing, so knowing how many entries you actually have is a genuinely useful signal. Feed it the output of TinyBee's String To List or Get List From File, and the Count becomes:

    • the max for an Incrementer reset condition (run N times, then stop)
    • a sanity check that your file list actually matched something (count of 0 means your glob pattern found nothing)
    • the batch size of an image or prompt list, so a downstream node can plan around it

    How it works

    It's len(string_list) under the hood - the node is declared with INPUT_IS_LIST, which is ComfyUI's way of saying "this input is a whole list, not a single value." It counts the entries, not the characters. The output is a plain INT you can compare, clamp, or plug into anything that takes a number.

    The inputs that matter

    Just one:

    • string_list - the list to count. It has to be an actual list - wire it from another TinyBee list node, not from a single text string. If you hand it a single string, you're counting a one-element list and you'll get 1 back every time, which is the classic "why is this always 1" moment.

    One output:

    • Count - the number of entries, as an INT.

    Installing it

    Part of the TinyBee pack: ComfyUI Manager → Install Custom Nodes → search "ComfyUI-TinyBee", install, restart. Or manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/TinyBeeman/ComfyUI-TinyBee
    

    It sits under 🐝TinyBee/Lists. Stdlib only - no extra install steps for this one.

    Common issues

    The one real trap is feeding it a plain string and getting 1. Remember: lists come from list-producing nodes (String To List, Get File List, Combine Lists). If you need the length of a string in characters instead, that's a different node - this one counts entries only. And if your count is 0, check your upstream glob or filter before blaming the node; 0 means the list arrived empty, which is often a path or pattern problem earlier in the chain.

    Category🐝TinyBee/Lists

    Inputs (1)

    NameTypeDefaultDescription
    string_listSTRING

    Outputs (1)

    NameTypeDescription
    CountINT