Nodes/comfyui-easyapi-nodes/FilterValueForList
ComfyUI Node

FilterValueForList

FilterValueForList – ComfyUI Node

By lldacing·Created 3 years ago·Updated 8 months ago· 96
FilterValueForList
  • lst
  • LIST
key
value

What it is

FilterValueForList is a search-by-key-and-value filter for a list of dict-like elements - think a LIST of JSON objects, the kind of structure you'd get back from an API response or a batch of metadata records flowing through a workflow. Give it a list, a key, and a value, and it hands back only the elements where that key matches that value. If nothing matches, it returns None rather than an empty list, which is worth remembering when you're wiring up whatever comes next.

This is the kind of node you reach for once a workflow stops being "one image in, one image out" and starts being "a batch of records, and I need to pick out the ones that satisfy some condition" - filtering a list of detection results down to just the ones tagged a certain way, picking a specific entry out of a batch of metadata by an ID field, that sort of thing. It's plumbing for data-shaped workflows, not image-shaped ones.

How it works

The matching itself is straightforward key/value equality over each element in lst. There's no operator selection here (no "contains", "greater than", and so on) - it's a direct match: does this element's key equal value? Keep, or discard. Given that key and value are both plain STRING inputs rather than typed fields, expect the comparison to be string-based - if your list elements store numbers, worth double-checking whether the node compares them as strings or coerces types, since a mismatch there ("5" versus 5) is a classic source of a filter silently matching nothing.

Inputs and outputs

  • lst (LIST, required) - the list of elements to filter.
  • key (STRING, default empty) - the field name to check on each element.
  • value (STRING, default empty) - the value that field must equal to keep the element.

One output, named LIST (type LIST) - the filtered results, or None if nothing matched.

Installing it

Bundled with comfyui-easyapi-nodes. Easiest path is ComfyUI Manager: search "comfyui-easyapi-nodes", install, restart ComfyUI. Manual install:

cd ComfyUI/custom_nodes
git clone https://github.com/lldacing/comfyui-easyapi-nodes.git
cd comfyui-easyapi-nodes
pip install -r requirements.txt

This node is pure Python list logic with no special dependency, but running the requirements install matters for the pack as a whole - several sibling nodes do need extra packages, and a partial install is the usual reason people see import errors after adding the pack. git pull in the same folder to upgrade later.

Common issues

"Nothing matches, even though I'm sure the value is there." Two usual suspects: type mismatch (the field is stored as a number but you typed a string into value, or vice versa), and exact-match sensitivity - this isn't a "contains" filter, it's an equality check, so a partial string won't match. Also check for stray whitespace in either the actual data or what you typed into the value field; equality checks are unforgiving about that.

"Downstream node crashed with a None-related error." That's the empty-result case. This node returns None, not an empty list, when nothing matches - so anything downstream that assumes it's always getting a list needs to handle that case explicitly, whether that's a conditional check or one of this pack's IsNoneOrEmpty / IsNoneOrEmptyOptional nodes to catch it before it causes a crash further down the graph.

"I need to filter on more than one field, or with a comparison other than equals." This node doesn't support that - it's single-key, single-value, equality-only. For anything more elaborate you'd be looking at a more general-purpose scripting node, or chaining multiple filter steps if your logic can be expressed as successive equality checks.

CategoryEasyApi/Utils

Inputs (3)

NameTypeDefaultDescription
lstLISTObject列表,如[{"name": ""}]
keySTRING
valueSTRING

Outputs (1)

NameTypeDescription
LISTLIST符合过滤条件的列表