Nodes/ComfyUI_NYJY/GetItemFromList(NYJY)
ComfyUI Node

GetItemFromList(NYJY)

Pluck one element out of a list wire

By aidenli·Created 2 years ago·Updated 4 months ago· 146
GetItemFromList(NYJY)
  • array
  • item
index0

Some nodes hand you a whole list where you only need one item - a batch of strings from a split, a list of file paths, an array a JSON node produced. GetItemFromList does the obvious thing: take the list, take an index, give back the element at that position. It accepts any input type (*), so it works on lists of strings, numbers, or anything else a node emits as a list. It's one of those five-second utilities you forget exists until a workflow has you stuck at "I need the second prompt out of this array."

How it works

The node runs with INPUT_IS_LIST = True, which means ComfyUI presents each input as a list at runtime. If the incoming value is actually a list, it indexes into it: array[index]. Indexing is zero-based like Python - index 0 is the first item. If the index is out of range it returns an empty result instead of crashing. And if the input turns out not to be a list, it just passes the value through untouched, so you never get a type error from it either way.

Inputs and outputs

  • array - required, type *. Any list-bearing wire.
  • index - required INT, default 0. Zero-based position.

Output: item, type * - the element at that index (or the input passed through, or empty on out-of-range).

Installing

Pack install, same as every NYJY node: ComfyUI Manager → Install via Git URL → https://github.com/aidenli/ComfyUI_NYJY, restart. Nothing extra to configure.

When you'll actually use it

The canonical setup in this pack: the JSON logic nodes or an LLM answer produce an array, and you want element N fed into the next node - e.g. grabbing the first line of a multi-line generation, or picking one of several candidate prompts before they hit the text encoder. It's also the natural partner for anything that emits lists of numbers, letting you pull a specific value into a sampler parameter.

Two honest notes. First, it's a fixed index - if you need to iterate or conditionally select, you'll be wiring an index source into it and re-running. Second, like all the *-typed nodes in this pack it will happily take almost anything, which is convenient and also means a wrong wire won't complain loudly. Keep the source obvious and this node is invisible-in-a-good-way glue. For a single index and a single element it's exactly as much node as you need.

CategoryNYJY/logic

Inputs (2)

NameTypeDefaultDescription
array*
indexINT0

Outputs (1)

NameTypeDescription
item*