ComfyUI Node

Get List Item

Pull the one frame you actually want out of a list

By kinorax·Created 4 months ago·Updated 25 days ago· 2
Get List Item
  • items
  • item
index0

IPT-GetListItem does one boring thing well: it returns a single item from a list by zero-based index. It's the node you reach for the moment a workflow hands you a batch or a list and you only want one thing out of it - the fifth frame of a video, the third cell of an XY plot, the image at position two of a directory read.

The pack it ships in, kinorax/ComfyUI-Info-Prompt-Toolkit, produces lists all over the place: its Video Reader outputs frames as a list, Image Directory Reader returns aligned lists of images, and XY Plot Start can emit its per-cell results as a list instead of a finished grid. So this node is the pack's answer to a recurring moment: I don't want the whole list, I want item N. It works on any list type too, not just images - strings, latents, whatever.

How it works

You give it items (any list) and index (an integer, default 0), and it hands back the item at that position. The important design choice is what happens when the index doesn't line up: instead of throwing, it returns None. Out-of-range index, empty list, a non-list passed in - all produce None, not a crash. That matters more than it sounds. ComfyUI's convention is that an unconnected optional input arrives as None, so a node downstream that treats None as "not connected" will just skip gracefully. In batch workflows where the list length can vary run to run, a getter that returns None instead of exploding is the difference between a failed run and a skipped frame.

The inputs that matter

  • items - the list. Optional; if it's not a list, you get None out.
  • index - zero-based position, default 0. There's no negative-index support, so -1 doesn't mean "last"; it means None.

One output: item, of the same type as whatever was in the list.

Installing it

This is part of the IPT pack, so install the pack once and restart ComfyUI:

cd ComfyUI/custom_nodes
git clone https://github.com/kinorax/comfyui-info-prompt-toolkit.git
cd comfyui-info-prompt-toolkit
pip install -r requirements.txt

Or let ComfyUI Manager handle it - search "ComfyUI-Info-Prompt-Toolkit". No models to download, no extra dependencies beyond the pack's requirements.txt.

Where people get burned

The off-by-one is the classic: lists are zero-indexed, so index: 1 gives you the second item. If you set index: 1 expecting "the first", you'll be debugging a subtly wrong frame for a while. The other habit worth having: since an out-of-range index returns None rather than an error, it composes beautifully with a fallback switch - pair this with something like an A/B or first-non-null switch and you can build "use frame N if it exists, otherwise use this default" without any Python. And if you need all the items as a batch, you don't want this node at all - you want the list flattened or batched elsewhere. This one is for when you want exactly one.

CategoryInfo-Prompt-Toolkit/Utility

Inputs (2)

NameTypeDefaultDescription
indexINT0Zero-based item index; unavailable indices return None
itemsoptCOMFY_MATCHTYPE_V3Optional list to select from

Outputs (1)

NameTypeDescription
itemCOMFY_MATCHTYPE_V3Selected item, or None when the list or index is unavailable