Nodes/ComfyUI-List-Utils/List: Get By Index
ComfyUI Node

List: Get By Index

Pull one item out of a ComfyUI List by position

By godmt·Created 2 years ago·Updated about a month ago· 16
List: Get By Index
  • ANY
  • *
index0

You've got a ComfyUI List running through your graph - ten seeds, five prompt variants, whatever - and you only want one of them. Not "process all ten and pick later," but grab exactly the third one right now and feed it downstream as a single value. That's what List: Get By Index does. It reaches into a List-processing stream and pulls out one item at a specific position.

How it works

Feed it a List-typed input and an index, and it returns the item at that position as a plain, single value - not a List anymore. Index 0 is the first item, and negative indexing works Python-style, so -1 grabs the last one regardless of how long the list turns out to be. That negative-index trick is genuinely useful when you don't know the list length ahead of time - say you built it from Split String or List Dir off a folder whose contents change - and just want "the last one" without a separate length check.

The important word in the node's own description is "List." This node is for ComfyUI's native List-processing values specifically - the ones that make downstream nodes run once per item. If what you actually have is a raw Python list bundled as one value (a PYLIST), this node won't see it the same way; you want its sibling, PyList: Get By Index, for that.

The inputs and outputs that matter

  • ANY - the List-processing value to read from. It accepts any type, which is what lets one node work whether you're indexing a list of strings, ints, images, or anything else.
  • index - which item to grab. 0 is first, -1 is last, and it accepts a huge range in either direction so you're not fighting an artificial ceiling.

There's exactly one output, typed * to match whatever went in, and it's a single item, not a list. Wire it straight into whatever expects that value on its own - a KSampler seed, a text prompt, an image input, anything that wants one thing instead of a batch.

How to install it

Through ComfyUI Manager, search "ComfyUI-List-Utils" and install. Or by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/godmt/ComfyUI-List-Utils.git

Restart ComfyUI afterward. No models, no extra Python packages - it's a lightweight primitives pack, and this particular node is just index arithmetic.

Common issues & troubleshooting

Downstream node errors on None with no obvious cause. This is the one real trap here: when the index is out of range, the node doesn't error - it silently returns None. That's fine if you're expecting it, but if your list length varies at runtime (built from a folder listing or a split string, say) and your index assumption doesn't hold, you'll get a None fed into whatever's next, and that node is usually what throws the confusing error. If something downstream complains about a missing or wrong-typed value, check whether this node's index actually landed inside the list's bounds before you go debugging the other node.

Connected to a PyList and nothing happens right, or the graph doesn't loop the way you expected. List and PyList are different container types in this pack on purpose - this node only speaks List. If your upstream value came from Create PyList, Merge PyList, or anything else that returns a PYLIST, run it through PyList To List first, or just use PyList: Get By Index directly instead.

You wanted a slice, not a single item. If you need a range of items rather than one, this isn't the node - reach for List: Slice, which keeps the result as a List instead of collapsing it to a single value.

Categorylist_utils

Inputs (2)

NameTypeDefaultDescription
ANY*Connect a ComfyUI List-processing value.
indexINT0-9007199254740992–9007199254740992Item index to read. 0 is the first item, -1 is the last item.

Outputs (1)

NameTypeDescription
**The item at the selected index. Returns None when the index is out of range.