Nodes/ComfyUI-YogurtNodes/ListIndex (Yogurt Nodes)
ComfyUI Node

ListIndex (Yogurt Nodes)

Grab the Nth thing out of any list — including backwards

By yogurt7771·Created 2 years ago·Updated 9 days ago· 1
ListIndex (Yogurt Nodes)
  • list_data
  • item
index0

ComfyUI is great at images and genuinely bad at lists. The graph model keeps everything in a queue - batches of prompts, lists of seeds, stacks of filenames - and sooner or later you need to reach into one of those and pull a single element out. That's exactly the job YogurtListIndex exists for. It takes any list-like object, an index, and hands you the item at that spot.

It's one node in a much bigger pack: ComfyUI-YogurtNodes, an all-in-one collection by yogurt7771 with 150+ nodes spread across images, masks, strings, logic, models, IO, and a row of LLM API wrappers. It's MIT-licensed, mostly docstring-driven, and nobody on the forums is talking about it - but the logic corner of the pack is solid, and this is one of the five list helpers (Index, Slice, Join, Length, Unique) that keep working without you noticing.

How it works

The mechanism is one line of Python: list_data[index]. What's useful is the semantics you get for free. The index input is an INT defaulting to 0, and it supports negative indices the way Python does - -1 is the last element, -2 the second-to-last. Want the 3rd item? Index 2. Want the final item of an unknown-length list? Index -1. No need to know how long the list is first.

The list_data input is typed as * (anything), and the item output carries whatever type the element is, so you can pull a STRING out and wire it straight into a prompt, a seed INT into a KSampler, a filename into a loader. The node is dumb in the best way - no conversion, no guessing, just indexing.

Where you'll actually use it

  • Picking one prompt out of a list you generated upstream.
  • Pulling a specific frame or batch element by position.
  • Reading the last value off a list you built inside a loop.
  • Debugging: wire any list into it with index 0 to see what's actually in there.

The main trap is the same one as in Python: an index past the end of the list errors the whole graph. If your list length varies at runtime, size your index from YogurtListLength first, or use a negative index to reach in from the back.

Install

Easiest is ComfyUI Manager: open it, search ComfyUI-YogurtNodes, install, restart. Manual works fine too:

cd ComfyUI/custom_nodes
git clone https://github.com/yogurt7771/ComfyUI-YogurtNodes
cd ComfyUI-YogurtNodes
pip install -r requirements.txt

Then restart ComfyUI and look under the "Yogurt Nodes" category. Dependencies are light (numpy, pillow, requests, opencv-python) and nothing here downloads models, so you're not signing up for anything heavy.

CategoryYogurtNodes/Logic

Inputs (2)

NameTypeDefaultDescription
list_data*任何支持索引访问的列表类型对象
indexINT0要访问的索引(支持负索引)

Outputs (1)

NameTypeDescription
item*