ComfyUI Node

EmAySee Tag Pruner

Strip the tags you don't want out of a booru-style prompt, case-insensitively

By EmAySee·Created about a year ago·Updated 4 months ago· 2
EmAySee Tag Pruner
    • cleaned_tags
    input_tagstag1, tag2, bad_tag, tag3, 1girl
    tags_to_removebad_tag, 1girl, solo

    You've got a comma-separated tag list, and there are tags in it you never want - maybe a model-specific tag that leaks in, 1girl or solo when you're deliberately doing a group scene, or a phrase that triggers a censorship word-swap. EmAySee Tag Pruner is a dead-simple filter: give it the tag list and a second list of tags to remove, and it hands back the cleaned list with the offenders gone, rejoined with ", ". It's the kind of glue node that saves you from hand-editing prompts every single generation.

    Its natural home is next to the pack's other text plumbing: an LLM produces tags (via the Oobabooga nodes or a Tag Parser), those tags pass through the pruner to drop the ones you've blacklisted, and the result flows into your prompt encoder or tag combiner. You can also hardwire it as a standing filter - keep tags_to_remove constant and just swap the input_tags from upstream.

    How it works

    Split-and-filter, with two details that matter:

    • Case-insensitive. It lowercases both sides before comparing, so 1girl in the input matches 1GIRL in the remove list. Good - booru tags are inconsistent about case.
    • Splits on commas and newlines. Inputs can be pasted as tag1, tag2, bad_tag or as a multiline list; both get tokenized the same way. Whitespace around each tag is stripped before comparison.
    remove_set = set(tag.strip().lower() for tag in re.split(r'[,\n]+', tags_to_remove) if tag.strip())
    

    Then each input tag that isn't in the removal set survives, and survivors are rejoined with ", ". Duplicates in the input are not deduped - if tag1 appears twice and isn't removed, it comes out twice. If you want dedup too, that's a different node (the pack has an EmAySee Remove Duplicate CSV for that).

    Inputs and output

    • input_tags - the comma-separated (or newline-separated) list to filter.
    • tags_to_remove - the blacklist; same format.

    The single output, cleaned_tags, is the surviving tags as a comma-joined string. That's it - this node has no other surface.

    Installing it

    Part of ComfyUI_EmAySee_CustomNodes - Manager search for the pack title, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/EmAySee/ComfyUI_EmAySee_CustomNodes
    

    Restart. No dependencies, no models.

    Where people get burned

    Two gotchas, both from the exact-match design. First, it's exact-string matching after lowercasing - it won't catch bad_tag_2 when you asked to remove bad_tag, and it won't remove "1girls" if your remove list says "1girl". Second, tags with meaningful spaces ("long hair" vs "long_hair") must match character-for-character; a booru list that uses underscores won't match a remove list typed with spaces. And remember the no-dedup behavior: if your upstream LLM is a repeat offender, run a dedup node after this one, not instead of it.

    CategoryEmAySee

    Inputs (2)

    NameTypeDefaultDescription
    input_tagsSTRINGtag1, tag2, bad_tag, tag3, 1girl
    tags_to_removeSTRINGbad_tag, 1girl, solo

    Outputs (1)

    NameTypeDescription
    cleaned_tagsSTRING