ComfyUI Node

Danbooru Tag Prompt

Turn messy text into clean Danbooru tags before you search

By L33chKing·Created about a year ago·Updated 12 months ago· 3
Danbooru Tag Prompt
    • TAGS
    tags
    normalizetrue
    dedupetrue
    sortfalse
    max_tags0

    Every pack has one unglamorous utility node that nobody blogs about and everyone ends up using, and for Danbooru FAISS Search Nodes that node is Danbooru Tag Prompt. It takes a messy string - tags, free text, whatever you pasted from somewhere - and hands you back a normalized, deduplicated, optionally sorted tag string. That's it. One string in, one string out. But it sits in front of the pack's search node for a reason, and that reason is that Danbooru's tag vocabulary is picky.

    Danbooru tags are standardized labels, not descriptions: 1girl, long_hair, looking_at_viewer. The anime models trained on Danbooru data (Illustrious, NoobAI, Pony partially) learned this exact vocabulary, so red_eyes prompts far better than "red eyes". This node exists to force your input into that shape before it hits a search or a text encoder.

    How it works

    Nothing magical - it's a string processor with four switches:

    • normalize (default on) - lowercases everything and replaces spaces with underscores. This is the important one. Reimu Hakurei becomes reimu_hakurei, which is what the search index and the models actually understand.
    • dedupe (default on) - removes duplicate tags, keeping the first occurrence. If your source list repeats 1girl four times, you get one.
    • sort (default off) - alphabetizes the result. Mostly useful if you're building a clean tag list for a tagger or a caption file.
    • max_tags (default 0, meaning unlimited) - keeps only the first N tags after processing. Handy for forcing a long search query down to something the API or index handles nicely.

    The output is a single comma-separated string. Comma-splitting is the parsing rule, so a tag containing a comma will not survive - that's inherent to the Danbooru format and not a bug.

    Where to use it

    Feed the output straight into Danbooru Lookup and Download's positive_prompt (or negative_prompt - it's great for cleaning up a negative like "monochrome, sketch, bad anatomy" before it becomes a vector). You can also run it in front of a text encoder for a tag-based anime model, as long as you remember one thing: this is a tag cleaner, not a prompt synthesizer. If your string already has attention weighting ((tag:1.3)), underscores you want to keep, or natural-language sentences you want preserved, leave normalize off or run it on a copy. It will happily mangle either.

    Install

    Same pack as the rest: ComfyUI Manager → search "Danbooru FAISS Search", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/L33chKing/ComfyUI-danbooru-FAISS-search
    cd ComfyUI-danbooru-FAISS-search
    pip install -r requirements.txt
    

    Restart ComfyUI and it shows up in the Danbooru category. It's the only node in the pack that does absolutely nothing on first run beyond what it does on every run - no model downloads, no index building. That makes it a nice first test after install: wire a string in, confirm you get clean tags out, and you've proven the pack loads.

    One honest caveat

    This node's quality ceiling is entirely inherited. It normalizes and dedupes, but it won't invent correct Danbooru tags or fix a wrong one - garbage in, tidier garbage out. If you're serious about tag quality for prompting or captions, the model still understands real Danbooru tags much better than it understands descriptions, so spend the effort upstream on getting the vocabulary right, and use this node to keep it clean on the way in.

    CategoryDanbooru

    Inputs (5)

    NameTypeDefaultDescription
    tagsSTRINGComma-separated tags or free text
    normalizeoptBOOLEANtrueLowercase, replace spaces with underscores
    dedupeoptBOOLEANtrueRemove duplicate tags (keeps first)
    sortoptBOOLEANfalseSort tags alphabetically
    max_tagsoptINT00–20480 = unlimited; otherwise take first N after processing

    Outputs (1)

    NameTypeDescription
    TAGSSTRING