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

ListFilter (Yogurt Nodes)

Keep only the list items you actually want

By yogurt7771·Created 2 years ago·Updated 9 days ago· 1
ListFilter (Yogurt Nodes)
  • list_data
  • filtered_list
pattern.*
invertfalse
ignore_casetrue
multilinefalse
dotallfalse

Lists are messy; this is the broom

ListFilter (Yogurt Nodes) takes a list and keeps only the items that match a regex pattern. That's it - but "that's it" carries a lot of weight, because once you start feeding ComfyUI real filenames, tags, or prompt segments, half the battle is deciding which of them you actually want.

The classic case is GlobFiles. That node hands you every path in a folder; you usually want a subset - only the .png files, or only the files that aren't backups. ListFilter does the trimming, and you can chain a ListLength after it to prove you got the count you expected.

How it works

Under the hood it's Python's re module with configurable flags:

compiled_pattern = re.compile(pattern, flags)
for item in list_data:
    matches = compiled_pattern.search(str(item)) is not None
    if matches != invert:
        result.append(item)

Two details matter. First, every item gets str()-ed before matching, so it works on any list - integers, paths, whatever - and the pattern always sees the string form. Second, the default pattern is .*, which matches everything, so the node starts life as a no-op passthrough. Nothing happens until you actually type a pattern. That's a feature: you can drop it into a workflow and iterate without breaking anything.

The inputs that matter

  • list_data - the list to filter.
  • pattern - your regex. Default .* (keep everything). This is the one you'll actually edit.
  • invert (default off) - flips it to "exclude matches" instead of "keep matches." Perfect for "everything except backups."
  • ignore_case (default on) - easy to miss. It defaults to case-insensitive, so \.png will happily keep PHOTO.PNG. Good default for filenames, mildly surprising when you need case sensitivity.
  • multiline and dotall - regex flag toggles you'll rarely touch. multiline makes ^/$ match per line; dotall makes . match newlines. Only relevant if your list items contain newlines.

Output: filtered_list, same type as what went in.

Installing it

This node ships in ComfyUI-YogurtNodes, a 152-node pack by the handle yogurt7771. ComfyUI Manager is the path of least resistance - search "ComfyUI-YogurtNodes" and install. Manually:

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

Restart, then find it under "Yogurt Nodes" (it shows up as "ListFilter (Yogurt Nodes)" in the menu). Filtering is pure stdlib - no model downloads, no API keys, no heavy dependencies. The pack's requirements.txt pulls in numpy, pillow, openai, google-genai, and requests for its image and LLM nodes; ignore all of that for this node, and skip the README's API-key sections too.

Gotchas worth knowing

A bad regex errors the node. Typo something like [unclosed and the whole node fails with a re.error - you'll get a traceback, and it's on you, not the pack. Test a nontrivial pattern on a text file before wiring it in.

The default ignore_case means "PNG" and "png" both match. The UI tooltip says "Case sensitive matching," which reads backwards from the behavior - the flag is named ignore_case and defaults to True. Trust the behavior, not the label.

Remember invert for negative filters. "Everything except" is one checkbox, not a regex nightmare like ^(?!.*backup).*$. Reach for the checkbox.

CategoryYogurtNodes/Logic

Inputs (6)

NameTypeDefaultDescription
list_data*List to filter
patternSTRING.*Regex pattern to match
invertoptBOOLEANfalseInvert the filter (exclude matches)
ignore_caseoptBOOLEANtrueCase sensitive matching
multilineoptBOOLEANfalseMultiline matching
dotalloptBOOLEANfalseDotall matching

Outputs (1)

NameTypeDescription
filtered_list*