ComfyUI Node

TagFilter

Keep only the categories you asked for

By sugarkwork·Created 2 years ago·Updated 6 months ago· 87
TagFilter
    • result
    tags
    posetrue
    gesturetrue
    actiontrue
    emotiontrue
    expressiontrue
    cameratrue
    angletrue
    sensitivetrue
    liquidtrue
    include_categories
    exclude_categories

    If you tag-then-generate - WD14 Tagger (or any booru tagger) describing an image, then feeding that tag string into a Danbooru-trained model like Illustrious or NoobAI - you know the problem. One image spits out forty tags, and twenty of them are facial-expression tags you don't care about or colors you're about to override anyway. TagFilter is the cleanup pass: it takes a comma-separated tag string, checks every tag against the pack's bundled category file, and returns only the tags that land in the categories you left checked.

    It's the flagship node of sugarkwork's comfyui_tag_filter pack, and honestly the rest of the family is this one idea split into specialized pieces. If you install a single node from this pack, this is it. TagFilter reads the category JSON that ships with the repo (it uses the big tag_category_v3.json, ~67k entries, by default), so it needs zero extra model downloads and runs instantly.

    How it works

    Every input tag is normalized - lowercased, spaces turned into underscores - then looked up in the category file. A tag like smile maps to categories like pose, expression; brown_hair maps to hair_color and color. The node keeps a tag only if one of its categories is on your "targets" list.

    The nine checkboxes on the node - pose, gesture, action, emotion, expression, camera, angle, sensitive, liquid - are category names made clickable. Then there are two free-text fields that matter more than they look:

    • include_categories - comma-separated category names to add. Type cloth and it behaves exactly like checking a box that doesn't exist yet. Type * and it keeps every categorized tag, checkbox state be damned.
    • exclude_categories - a blacklist that runs last. Want only clothing but no color tags? include_categories: cloth plus exclude_categories: color gets you there.

    Output is a single result STRING, which you wire straight into your prompt builder or text encoder. One nice touch: emphasis weights survive the trip. (smile:1.2) in, (smile:1.2) out - the node isn't flattening your careful weighting.

    Where people get burned

    The big one: all nine checkboxes are on by default, so TagFilter returns only those nine categories and silently drops hair, clothing, color, character names - everything else. First run looks like data loss if you expected pass-through. You didn't break it; that's the intended filter.

    Second: tags the category file doesn't know vanish without a word. WD14 emits plenty of tags this file hasn't categorized, and they just don't come back. Nothing errors, no "unknown tag" list. If a tag you want keeps disappearing, it's almost certainly not in the lookup.

    Third: the category data is best-effort. The author is upfront that the original tag_category.json was auto-sorted by an AI and contains mistakes, and only the newer files get manual fixing. Misclassified tags land in the wrong bucket, and since this node's whole job is bucketing, that's the one thing you can't debug from the node itself. When in doubt, open tag_category_v3.json in the pack folder and grep for the tag.

    Installing it

    ComfyUI Manager is the easy path - search "comfyui_tag_filter" and hit install. Or the manual route:

    cd ComfyUI/custom_nodes
    git clone https://github.com/sugarkwork/comfyui_tag_fillter
    

    Then restart ComfyUI. That's it - requirements.txt is empty and the category files ship in the repo, so there's no dependency dance and no model to fetch. The pack's README is Japanese, which is fine because the node UI speaks English; if you hit a confusing tooltip, the source is small and readable.

    Categorytext

    Inputs (12)

    NameTypeDefaultDescription
    tagsSTRING
    poseBOOLEANtrue
    gestureBOOLEANtrue
    actionBOOLEANtrue
    emotionBOOLEANtrue
    expressionBOOLEANtrue
    cameraBOOLEANtrue
    angleBOOLEANtrue
    sensitiveBOOLEANtrue
    liquidBOOLEANtrue
    include_categoriesSTRING
    exclude_categoriesSTRING

    Outputs (1)

    NameTypeDescription
    resultSTRING