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

ListFind (Yogurt Nodes)

Where in the list is it? Ask ListFind

By yogurt7771·Created 2 years ago·Updated 9 days ago· 1
ListFind (Yogurt Nodes)
  • list_data
  • element
  • index
default_index-1

The "where is it?" node

ListFind (Yogurt Nodes) answers one question: at what position does this element sit in this list? It returns an integer index, and an integer index is exactly what you need when you want to pull the element out with ListIndex, branch a Switch on position, or confirm that something appears where you expect it.

Where you actually feel the need for it: you've split a string into tokens with StringSplit, or globbed a folder, and you need to know the slot a particular value occupies - then grab its neighbors by index. It's a plumbing node, the kind you reach for mid-workflow when something just needs to be found.

How it works

This is a thin wrapper around Python's list.index():

try:
    return (list_data.index(element),)
except ValueError:
    return (default_index,)

Three behaviors fall straight out of that:

  • First match wins. index() returns the first occurrence; if the element is in the list twice, you get the earlier position. No "find all," no flags.
  • Missing elements don't error. Instead of blowing up, you get default_index, which defaults to -1 - the classic "not found" sentinel.
  • Matching is exact equality, same as ListContains: 2 and "2" are different, and there's no substring logic.

The inputs and the output

  • list_data - any list-like object. From GlobFiles, StringSplit, ToList, wherever your list lives.
  • element - what you're hunting for.
  • default_index (default -1) - the value returned when the element isn't in the list. The only optional input, and it matters more than it looks.
  • Output: index (INT). Wire it into ListIndex, a Switch, or anything that takes an integer.

The -1 trap

Here's where people actually get burned, and it's subtle: -1 is a valid Python index. It means "the last element." So if you pipe ListFind's "not found" (-1) straight into a node that indexes the list, you won't get an error - you'll silently get the last list item, which is almost never what you meant.

The fix is to change default_index. If you need a "nothing was found" that can't be confused with a real position, set it to something out of range like -999, and check for that sentinel downstream. For a beginner, the honest advice is: know what the downstream node does with the index before you trust the default.

Installing it

ComfyUI-YogurtNodes is a 152-node pack by yogurt7771 - this node is one small corner of it. Manager is easiest: search "ComfyUI-YogurtNodes" and install. By hand:

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

Restart ComfyUI and you'll find it under "Yogurt Nodes" as "ListFind (Yogurt Nodes)". This node is pure stdlib - no model files, no API keys. The pack's requirements.txt (numpy, pillow, openai, google-genai, requests) exists for its image and LLM nodes; nothing here needs them, and you can skip every API-key setup section in the README.

When you'd rather not

If your list is huge or you're hunting inside strings rather than list slots, this is the wrong tool - that's ListFilter's job (regex matching), or a text node's. ListFind is for when you need the position, not a yes/no and not a subset. Set a sane default_index, remember the -1 gotcha, and move on.

CategoryYogurtNodes/Logic

Inputs (3)

NameTypeDefaultDescription
list_data*Any list-like object
element*Element to find
default_indexoptINT-1Index to return if element not found

Outputs (1)

NameTypeDescription
indexINT