Danbooru Tag Generator
Turn a sparse anime prompt into a full Danbooru tag list
- output
- llm_output
You typed 1girl, hatsune miku, sitting and got something technically correct but weirdly bare - no background, no clothing detail, no camera angle, none of the little tags that make an anime model actually cook. PromptDanTagGen is the fix. Hand it a few seed tags and it writes the rest of the prompt: a coherent list of Danbooru tags fleshing out the character, scene, and details, in the exact vocabulary an Illustrious, NoobAI, or Pony model wants to hear.
It's a wrapper around KohakuBlueleaf's DanTagGen model - a small LLM trained to autocomplete Danbooru tag strings. Same author who made LyCORIS and the Kohaku-beta SDXL finetune Illustrious is built on, so this is someone who lives deep in the anime-model world, not a weekend project. The node itself is by huchenlei, a ComfyUI core contributor. The name looks like it might call some paid tag API - it doesn't. Everything runs locally on the little model it downloads, no key, no account.
Why you'd reach for it
Danbooru-trained models speak in tags, not sentences, and good output means knowing the vocabulary - the right tag for a pose, a lighting setup, a framing. Most people don't have hundreds of booru tags memorized, and that's the gap DanTagGen closes. It's read the tag co-occurrence patterns off the whole board, so given 1girl, cafe it knows the crowd that shows up: indoors, window, sitting, coffee, looking at viewer, depth of field. In the workflow it's a front-end for your positive prompt: seed tags in, full tag string out, feed it to CLIP Text Encode.
How it works
Under the hood it's a text-to-text language model doing constrained autocomplete. You give it the known parts of the image - character, artist, rating, aspect ratio - and it generates general tags to fill out the rest, biased by how long you asked. Because it trained on real Danbooru posts, the tags it invents actually go together the way they do on the board: correlated tags reinforce instead of fighting each other.
By default it loads through HuggingFace transformers - fine, not fast. The README notes you can install llama-cpp-python and drop in a GGUF version for quicker inference; only worth it if you generate a lot of prompts and the wait annoys you.
The inputs and outputs that matter
A lot of fields, but a beginner touches a handful:
general- your seed tags, the multiline box. The one you actually fill in: put your core idea here (1girl, solo, standing) and let the model expand around it.target- how much prompt to generate:very_short(~10 tags),short(~20),long(~40),very_long(~60). The author recommendsshortorlong; the extremes are either too thin or a tag soup that dilutes your intent.rating-safe,sensitive,nsfw, ornsfw, explicit, steering the content level of the tags it adds, matching Danbooru's own rating axis.model- which DanTagGen checkpoint (alpha,beta,delta,delta-rev2).delta-rev2is newest; the older ones exist mostly for reproducibility.temperature- default1.35. Higher = more adventurous, varied tags; lower = more coherent. If output feels chaotic, drop it a bit.
The rest - artist, characters, copyrights, special_tags, width/height, blacklist (a regex ban-list for tags you never want), escape_bracket - are there when you need them; ignore them on a first run.
Two outputs, both strings. output is the finished, cleaned tag prompt - wire that into your CLIP Text Encode (Prompt) text input (right-click the CLIP encode and "convert text to input" to expose the socket). llm_output is the raw, unprocessed generation, handy for debugging what the model actually produced before cleanup.
Installing it
Easy path is ComfyUI Manager: search ComfyUI_DanTagGen, install, restart. Manual works too:
cd ComfyUI/custom_nodes
git clone https://github.com/huchenlei/ComfyUI_DanTagGen
then restart. First run downloads the DanTagGen checkpoint you picked from HuggingFace (KBlueLeaf/DanTagGen-*) into your local HF cache automatically - small, but you need to be online for that first pull. The repo's dtg.json is a working reference workflow to copy.
Common issues
The one that actually bites: it keeps trying to reach huggingface.co on every restart, even after the model's cached. A user hit exactly this running offline - startup threw Max retries exceeded / Failed to resolve huggingface.co, because the node does an online freshness check against the cached files. Offline, that stalls it. Fix: force HuggingFace offline so it trusts the cache instead of phoning home - set HF_HUB_OFFLINE=1 (or TRANSFORMERS_OFFLINE=1) before launching ComfyUI, once the model's downloaded. There's no path field on the node to point at a manual download, so cache-plus-offline-mode is the route.
Beyond that: the output only helps on Danbooru-trained models - Illustrious, NoobAI, Pony and their finetunes. Feed those tags to Flux or another natural-language model and you'll get worse results; those want prose, not a tag dump. And treat the generated list as a draft, not gospel - it'll happily add tags you didn't want, which is what blacklist and a lower temperature are for. Skim it before firing off a big batch.
Inputs (13)
| Name | Type | Default | Description |
|---|---|---|---|
| model | COMBO | 4 options: KBlueLeaf/DanTagGen-alpha, KBlueLeaf/DanTagGen-beta, KBlueLeaf/DanTagGen-delta, KBlueLeaf/DanTagGen-delta-rev2 | |
| artist | STRING | — | |
| characters | STRING | — | |
| copyrights | STRING | — | |
| special_tags | STRING | — | |
| general | STRING | — | |
| blacklist | STRING | — | |
| rating | COMBO | 4 options: safe, sensitive, nsfw, nsfw, explicit | |
| target | COMBO | 4 options: very_short, short, long, very_long | |
| width | INT | 1024256–4096 | — |
| height | INT | 1024256–4096 | — |
| escape_bracket | BOOLEAN | false | — |
| temperature | FLOAT | 1.35 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| output | STRING | — |
| llm_output | STRING | — |