Nodes/ComfyUI-TinyBee/Filter Words
ComfyUI Node

Filter Words

Keep the Tags That Actually Show Up

By TinyBeeman·Created about a year ago·Updated about a month ago· 1
Filter Words
    • filtered_words
    word_list
    description

    Here's a workflow pattern that shows up more than you'd think: you have a big vocabulary list and a short description, and you want to know which vocabulary words actually appear in the description. Filter Words is that check in node form. Give it a comma-separated word list and some text; it returns the words from your list that are present in the text, as a single comma-joined string. Think of it as a membership test that doubles as a tag filter.

    How it works

    Two inputs, one output:

    • word_list - your vocabulary, comma-separated. Entries are split on commas and whitespace-trimmed; empty entries are dropped.
    • description - the text to test against. Both inputs are plain strings.
    • filtered_words (output) - the words from word_list that were found, re-joined with ", ".

    The matching is a case-insensitive substring check: both the description and each word are lowercased, then it asks word in description. That's important for two reasons. It means "portrait" matches "portrait of a woman" - good. But it also means "art" matches "cartoon", because substring matching doesn't respect word boundaries. If your vocabulary has short words or words that appear inside other words, you'll get false positives and you should know that's the intended (if blunt) behavior.

    The output is a string, not a list - the found words come back comma-joined. That actually makes it convenient to drop straight back into a prompt, which feels like the point. Want to build a conditional prompt like "only include these quality tags if the description mentions a subject you care about"? This is your gate.

    Where you'd actually use it

    • Quality-tag gating: a list of masterpiece, best quality, highly detailed - include them only if the incoming prompt actually contains a matching keyword.
    • Category routing: filter which LoRA/style tags apply based on the prompt text.
    • Sanity checks: quickly verify that expected keywords made it into a generated description or caption.

    Installing it

    This one lives in the 🐝TinyBee/Util section of ComfyUI-TinyBee:

    1. ComfyUI Manager → Install Custom Nodes → search "ComfyUI-TinyBee" → Install, then restart ComfyUI.
    cd ComfyUI/custom_nodes
    git clone https://github.com/TinyBeeman/ComfyUI-TinyBee
    

    Restart after cloning. No models, and this node is pure string logic - the pack's requirements.txt (pillow, jsonata) isn't touched by it at all.

    Gotchas

    The substring matching is the whole game here. If your word list contains anything short (cat, an, the), you'll get noise from words that merely contain them - cat matches cathedral, scatter, certificate. If that matters, keep your vocabulary to distinctive terms, or do the substring filtering upstream where you control the text. Also note the output is a single string, so if you wanted a list you'll need a Split List / String To List node afterward (TinyBee has both). And there's no dedup: a word that appears twice in the list comes back twice. Minor, but visible if you're building prompts off the result.

    Category🐝TinyBee/Util

    Inputs (2)

    NameTypeDefaultDescription
    word_listSTRING
    descriptionSTRING

    Outputs (1)

    NameTypeDescription
    filtered_wordsSTRING