ComfyUI Node

filter

Filter a list with a boolean mask — and yes, the polarity is inverted

By StableLlama·Created about a year ago·Updated about 16 hours ago· 48
filter
  • value
  • filtered_list
filter

Say you generated twenty images and a face-detector flagged twelve of them. You want to keep the eight good ones and hand them downstream - but only those eight. filter is the node that does exactly that: take one data list of values, one data list of booleans, and get back the subset where the boolean says "keep."

It's part of Basic data handling, StableLlama's zero-dependency utility pack. This is the Data List family's masking node, and it comes with a genuine footgun you should know about before your first run.

How it works

You feed two parallel lists into value and filter. The node zips them together - element 0 of value pairs with element 0 of filter, and so on - and keeps only the items where the filter boolean is False.

Read that again. The filter keeps the False entries. A True in the mask drops the corresponding value. Most people, on first instinct, expect True = keep, and if you build your mask the intuitive way you'll get exactly the opposite of what you wanted. If that catches you, the fix is either to invert your mask or use the sibling filter select node, which returns separate true and false outputs so there's no polarity to get wrong.

The output filtered_list is a data list, so downstream nodes process each kept item individually - exactly what you want after a quality pass.

The inputs that matter

  • value (*) - the data list you're filtering.
  • filter (BOOLEAN, forced input) - the mask; a matching data list of booleans. It's marked forceInput, so it has to come from another node rather than a plain widget - the pack's boolean logic nodes or a comparison feeding it are the usual sources.

Installing it

ComfyUI Manager → search "Basic data handling", or:

cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling

Restart. No dependencies, no models.

Common issues

  • "It kept everything / it kept nothing." Classic polarity flip - your mask is backwards relative to the node's False = keep behavior. Invert it.
  • "The lists are different lengths." The docs say the shorter list's last element gets repeated to match, but the shipped code actually uses a plain zip, which stops at whichever list runs out first. Mismatched lengths silently truncate. Keep your mask the same length as your value list.
  • "I only want one branch." If you need both the kept and the dropped sets - for example to compare pass vs. fail - filter select is the node for that.
CategoryBasic/Data List

Inputs (2)

NameTypeDefaultDescription
value*
filterBOOLEAN

Outputs (1)

NameTypeDescription
filtered_list*