Nodes/Comfyui-General-API-Node/Get List Element (List) (FeiMao-326)
ComfyUI Node

Get List Element (List) (FeiMao-326)

Grab one item out of a list by index — the smallest node in the pack, and one you'll keep using

By FeiMao-326·Created 12 months ago·Updated 5 months ago· 0
Get List Element (List) (FeiMao-326)
  • list_input
  • item
index0

Indexing is the most boring operation in programming and the most missing one in ComfyUI's core. You split a string into a list, and then... what? Most workflows end up re-splitting or stacking if-else nodes just to reach element number three. This node is the two-input fix: a list goes in, an index goes in, one string comes out.

How it works

Inputs are list_input (the pack's LIST type) and index (an integer, default 0, minimum 0). It returns list_input[index] as a plain STRING named item. That's it - but the details are where it earns its keep:

  • Out-of-range indexes don't crash. Ask for index 7 of a 3-item list and you get back an empty string (with a printed warning), not a broken workflow. That's the right failure mode for a graph: one empty wire you can see, versus a hard error mid-run.
  • Non-list input (like if you wire a plain string by mistake) also returns an empty string instead of exploding.
  • Indexing starts at 0, matching the way ComfyUI counts everywhere else. If you think "second item = 2," you'll get the third one.

Where it fits

The node is designed to pair with the pack's Text Split By Delimiter, which outputs a LIST from a split string. The classic pattern: an LLM or a file hands you a comma-separated set of prompts, Split turns it into a list, and Get List Element picks which one to generate this run. Wire a seed or an integer from elsewhere into index and the "which prompt" choice becomes part of the graph's logic instead of something you edit by hand.

Because the output is a plain STRING, it plugs into anything - CLIP Text Encode, prompt templates, the General API Node, Show Text for verification. The only constraint is on the input side: the LIST type is this pack's own, so it connects cleanly within the pack, and you may need an adapter if you're pulling a list from a third-party pack that defines its own list type.

A trap to avoid

The index input is a fixed widget by default. If you want it driven by another node (say, an iterator counting up), remember to convert it to an input via right-click → "Convert to Input," the same ritual as every other widget in ComfyUI. Forgetting that leaves you manually typing index numbers, which defeats the whole point.

Inputs and outputs

  • list_input (LIST) - the list to index into.
  • index (INT) - zero-based position, min 0.
  • item (STRING) - the element at that index, or "" if out of range.

Installing

It's part of the FeiMao-326 pack, so you don't install it alone. ComfyUI Manager (search "Comfyui-General-API-Node") or the manual route:

cd ComfyUI/custom_nodes
git clone https://github.com/FeiMao-326/Comfyui-General-API-Node.git
cd Comfyui-General-API-Node
pip install -r requirements.txt

Restart ComfyUI, then find it under Add Node → FeiMao-326 → Get List Element. Dependencies are minimal - openai, numpy, Pillow, requests - and there are no models to download.

CategoryFeiMao-326

Inputs (2)

NameTypeDefaultDescription
list_inputLIST
indexINT0

Outputs (1)

NameTypeDescription
itemSTRING