ComfyUI Node

enumerate

Add numbers to a list — Python's enumerate, in graph form

By StableLlama·Created about a year ago·Updated 4 days ago· 48
enumerate
  • list
  • list
start0

Sometimes you don't just need the items in a list - you need to know where each one sits. Frame 7 of a video sequence. The third prompt in a batch. Position matters when you're naming outputs, pairing two batches, or debugging which element failed. enumerate gives every item an index: it takes a data list and returns a list of [index, value] pairs, which is Python's enumerate() brought into the graph.

It's from Basic data handling, StableLlama's zero-dependency pack. This one is a "list node" in the data-list sense - it fans out, so each [index, value] pair goes to downstream processing individually, which is exactly what you want when position drives the result.

How it works

Under the hood it's enumerate(input_list, start): it walks the list, pairs each element with its position, and returns a new list of those pairs. The start input sets the first index - default 0, but set it to 1 and your first item becomes index 1 (handy when you're building human-facing numbering that shouldn't start at zero). Its output is marked as a list, so downstream nodes run once per pair.

The output shape is the thing to wrap your head around: each element isn't just your original value, it's a two-element list [index, value]. So whatever you connect downstream needs to be able to take that pair - typically you'll pull the index and the value apart with the pack's get-item nodes, or feed the pair into something that understands it.

The inputs and the output

  • list (ANY) - the data list to enumerate.
  • start (INT, optional, default 0) - the index of the first item. 0 for computer-style indexing, 1 for human-style.
  • list (output, is a list) - the enumerated result: each element is a [index, value] pair.

Installing it

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

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

Restart ComfyUI. Zero dependencies, no models to fetch.

Troubleshooting

  • "Downstream got a list instead of my value." Yes - that's the whole design. The output elements are [index, value] pairs, not raw values. If you expected your strings back, you're one get item short. Check whether the receiving node wants the pair (for numbering) or the raw value (then don't enumerate; just use the plain list).
  • "Indexes start at 0 and I wanted 1." Use the start input. Set it to 1 and human readers stop asking why frame one is labeled zero.
  • Pairing two batches? Enumerate both, then combine by index. It's the honest way to zip two lists that were generated separately - just make sure the start values match or you'll be pairing them off by one.
CategoryBasic/Data List

Inputs (2)

NameTypeDefaultDescription
list*
startoptINT0

Outputs (1)

NameTypeDescription
list*