ZF Any Filter
The polite guard node that keeps empty lists out of your Any Switch
- value
- value
If you build workflows around rgthree's Any Switch, you've hit the classic failure: a folder loader upstream comes back with an empty list, and Any Switch - which just picks the first non-null input - treats that empty list as a valid value. So instead of skipping the dead route and falling through to the live one, it feeds an empty list into your sampler and the whole thing explodes or silently no-ops. ZFAnyFilter (display name "ZF Any Filter") is the node you drop between a data source and the switch to fix exactly that.
It's one node, but it's really three features bundled: an empty-list guard, a content-based text filter, and a way to intentionally stop or skip a route with None or "". All of it operates on any ComfyUI value - that's why the value input and output are both * (the wildcard type).
The inputs that matter
Only a few, and they're a matched pair:
condition- when the action applies: input is empty / not empty / always, plus six text rules (contains, doesn't contain, equals, doesn't equal, starts with, ends with any of your filter lines).output_action- what happens when the condition matches: outputNone(skip this route), output""(intentionally stop on this route), pass the input through, or remove the specified content and pass the rest.filter_content- the actual filter lines, one per line, no regex. Plain literal text only.case_sensitive- defaultTrue. Turn it off for case-insensitive matching.
One heads-up: the dropdown labels are Simplified Chinese (输入为空, 文本包含任一项, etc.) even in an English install - the pack ships a zh locale and the enum values are literally those strings. The tooltips on each field are in English, and the mapping is short, so you'll get used to it in a run or two.
Why the empty-list guard matters
The _is_empty check is careful in a way that matters for ComfyUI: a 0 integer is not empty, and False is not empty - only genuinely empty containers, empty strings, empty tensors, and None count. So you can filter a value that is legitimately 0 or False without it being swallowed. And when the condition matches, the action list is what gives you control: None tells an Any Switch to skip the route entirely, while "" makes the switch stop on that route on purpose - the README's "intentionally block every text value on this route" trick.
Unmatched values always pass through unchanged, so the node never corrupts data it isn't acting on.
The common recipes
These are the four combos the author documents, and they cover most real uses:
Input is empty+No output- safely skip empty routes.Always+Empty text- intentionally block every value on this route.Text contains any item+No output- skip text containing an unwanted marker.Text contains any item+Remove specified content- strip words or symbols while keeping the rest of the string.
Installing it
The pack is dependency-free, so install is the standard two-liner:
cd ComfyUI/custom_nodes
git clone https://github.com/Z-yaofang/ZF-ComfyUI-Helper
Restart ComfyUI, or search ZF-ComfyUI-Helper in ComfyUI Manager. No models, no requirements.txt. The node lives under ZF Helper/Flow.
The honest caveat
Any Filter sits in the "graph as a small program" layer, and that layer has a known cultural tension: routing nodes that erase types make graphs faster to build and harder to debug - the "Anything Anywhere" backlash is the extreme version. This node is on the restrained end (it filters, it doesn't wire-match), but it's still an abstraction you'll have to remember is there when something downstream stops working. Use it where a guard genuinely earns its keep - feeding folder loaders into switches - rather than sprinkling it everywhere.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| condition | COMBO | 输入为空 | Choose when the output action is applied. |
| output_action | COMBO | 无输出(None,跳过此路) | Choose the result produced when the condition matches. |
| filter_content | STRING | One literal word, phrase, or symbol per line. Regular expressions are not used. | |
| case_sensitive | BOOLEAN | true | Whether text matching distinguishes uppercase and lowercase letters. |
| valueopt | * | Accepts any ComfyUI value, including an empty list. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| value | * | — |