ComfyUI Node

get item

Pull any position out of a list — negative indices work too

By StableLlama·Created about a year ago·Updated 4 days ago· 48
get item
  • list
  • item
index0

Lists are indexed, and sometimes you need item #3 - or the second-to-last, or the one at a position you computed elsewhere in the graph. get item retrieves any element of a data list by index, with Python's full indexing semantics: zero-based, negative indices count from the end, and out-of-range returns None instead of blowing up.

It's part of Basic data handling, StableLlama's zero-dependency utility pack.

How it works

A single list[index] lookup, wrapped in a try/except so a bad index gives you None rather than a workflow-ending error. The interesting bit for workflow builders: index is itself a connectable INT input, not just a widget. So the position you read can be computed by another node - a random index node, a loop counter, the index-of-value node - which turns "get item" into a dynamic selector rather than a fixed pick.

Indexing rules that matter:

  • 0 is the first element.
  • -1 is the last element, -2 the second-to-last, and so on.
  • Anything out of range → None, not an error.

The inputs and output

  • list (*) - the data list.
  • index (INT, default 0) - which position to read. Wire it up for dynamic selection.
  • item (*) - the retrieved element, or None if the index misses.

A realistic use

Pick a specific frame from a batch to inspect, select a middle prompt from a prompt list to test, or drive a manual carousel: a random node feeding index gives you a different element of the list on every run. Since the output is a single value, it plugs straight into whatever consumes that type.

Installing it

ComfyUI Manager → search "Basic data handling", or:

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

Restart. No dependencies, no models.

Common issues

  • "I got None back." The index was out of range (or the list is empty). If you expect an element, check the list length - the pack's compare length or length node makes that easy.
  • "I wanted the last item and set -1, still confused." Negative indexing works: -1 is the last element. Just remember you're indexing, so -1 isn't "one from the front."
  • "I need where a value lives, not what's at a position." That's the index node - it searches by value and returns the position. Get item is the reverse operation.
CategoryBasic/Data List

Inputs (2)

NameTypeDefaultDescription
list*
indexINT0

Outputs (1)

NameTypeDescription
item*