Nodes/ComfyUI-EreNodes/Prompt Filter
ComfyUI Node

Prompt Filter

A spellchecker for booru-tag prompts

By Erehr·Created about a year ago·Updated a day ago· 69
Prompt Filter
    • STRING
    prompt
    csv_filedanbooru.csv
    alias_handlingUse alias

    There's a well-known piece of tag-prompting advice: stop guessing at the Danbooru vocabulary and look up the actual tag, because the model understands real tags so much better than natural-language approximations. Prompt Filter is that advice turned into a node. It takes a prompt and a tag dictionary, strips out everything the dictionary doesn't know, and normalizes aliases to canonical names. If you're feeding a prompt into an anime/SDXL model and you keep getting "the model ignored half my tags" energy, this node shows you which of your tags were never real to begin with.

    What it is

    The one genuinely analytical node in ComfyUI-EreNodes (Erehr's prompt-management pack). The rest of the pack is about building and toggling prompts; this one is about validating them against a known-good tag list. It ships with three CSV dictionaries from the pack's __autocomplete__ folder: danbooru.csv, e621.csv, and the merged danbooru_e621_merged.csv (the tag lists are community-sourced via DraconicDragon's data). If you add your own CSV with the same columns, it shows up in the dropdown automatically.

    How it works

    Every token in your prompt (split on commas and newlines) gets cleaned: lowercased, underscores turned into spaces, and LoRA/embedding syntax, weight suffixes, and wrapping brackets stripped. Then it's checked against the dictionary. A token passes if it's a known tag or a known alias of one. The alias_handling dropdown decides what happens to aliases:

    • Use alias - keep the alias exactly as you typed it.
    • Use main - replace it with the canonical tag.
    • Use both - emit both, main first.

    Known duplicates collapse, order is preserved, and the survivors are re-joined with commas. If the CSV file is missing, the node quietly returns your prompt untouched.

    Inputs and outputs

    • prompt - the STRING to filter (forced input).
    • csv_file - which dictionary to validate against: e621.csv, danbooru_e621_merged.csv, or danbooru.csv. The merged one is the sensible default for mixed models.
    • alias_handling - Use alias, Use main, or Use both.
    • Output - one STRING, the filtered tag list, ready for CLIP Text Encode.

    Installing it

    ComfyUI Manager: search "EreNodes", install, restart. Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Erehr/ComfyUI-EreNodes.git
    

    Restart; the node sits under EreNodes. Only dependency is safetensors, already bundled with ComfyUI.

    Gotchas

    This node is destructive by design, and you need to accept that. It strips weights ((tag:1.2) loses the emphasis), brackets, embeddings, LoRA markup, and every unknown token - so it's a filter, not a validator you run at the end to tidy up. Run it early in the graph and build your final string downstream. It's also squarely a booru-paradigm tool: it's built for the Danbooru/e621 vocabulary that Illustrious, NoobAI, and Pony understand, and it's pointless on natural-language models like Flux - those want prose, and this node will happily delete your prose. One more gotcha specific to Pony users: underscores become spaces, so score_9 gets mangled into score 9, which is exactly the wrong transformation. If Pony score tags are your bread and butter, this node isn't for you.

    CategoryEreNodes

    Inputs (3)

    NameTypeDefaultDescription
    promptSTRING
    csv_fileCOMBOdanbooru.csv3 options: danbooru.csv, danbooru_e621_merged.csv, e621.csv
    alias_handlingCOMBOUse alias3 options: Use alias, Use main, Use both

    Outputs (1)

    NameTypeDescription
    STRINGSTRING