ComfyUI Node

count

How many of these made it through? Ask, don't eyeball.

By StableLlama·Created about a year ago·Updated 4 days ago· 48
count
  • list
  • value
  • count

"How many of these actually made it through?" - that's the question count answers. Feed it a list and a value, and it tells you how many times that value appears in the list. It sounds like a niche utility, and it is - but it's the node you reach for when you're debugging a batch and can't tell whether your filter dropped everything, or when you want a workflow to decide something based on how many items survived.

It's part of Basic data handling, StableLlama's zero-dependency pack. The list nodes in this pack split into two camps - "data list" nodes that process items individually, and LIST nodes that treat the whole collection as one value - and count sits in the data-list camp: it takes a whole list in and hands you a single number.

How it works

The node marks its list input as INPUT_IS_LIST, meaning it receives the entire batch at once rather than one item per run. It then does Python's list .count(value) - an exact equality count over every element. Output is a single INT.

The one subtlety worth knowing: matching is exact. 1 and "1" are different values, "cat" and "Cat" are different, and a float 1.0 doesn't match an int 1. If your list and your search value came from different paths, type mismatches are the most likely reason a count comes back as zero when you're sure it shouldn't.

The inputs and the output

  • list (ANY) - the batch to search. Wire it from a create-data-list node or any list-producing node in the pack.
  • value (ANY) - what to count. Can be any type, as long as it matches the list's elements.
  • count (output, INT) - the number of occurrences.

Installing it

Install Basic data handling from ComfyUI Manager (search "Basic data handling"), or:

cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling

Restart ComfyUI. No dependencies, no model files - nothing to break.

Troubleshooting

  • "It says 0 and I can see the value in the list." Almost always a type mismatch - check int vs string, float vs int, case sensitivity. If the list came out of a text-split node and you're searching with a manually typed value, they're strings; if one side is a number, that's your culprit.
  • "I wanted the length of the list, not a count of one value." Wrong node. The pack's length node gives you the total number of items; count is specifically "how many times does this value appear." Easy to mix up at a glance because both take a list and return an INT.
  • Wiring a non-list into list. If you connect a single value instead of a list, the count behavior is undefined-ish - it'll count against whatever shape it received. Keep the pack's list types consistent: data lists and LISTs are different containers.
CategoryBasic/Data List

Inputs (2)

NameTypeDefaultDescription
list*
value*

Outputs (1)

NameTypeDescription
countINT