TK Danbooru Tag Getter
Sort a messy prompt into tag categories, then drop or weight them
- tag_bundle
- Tag String
Prompts accumulate junk. You paste a character's trigger phrase, add a lighting node, some camera tags, a speech_bubble that slipped in from a booru post - and now you want to keep four of those things and bin the rest, without hand-editing the prompt every run.
TK Danbooru Tag Getter does that one job: it takes a prompt, recognises the tags inside it, sorts them into twelve categories, and gives you back only the categories you asked for. It's the text-sorting node of TK Toolkit (anima-toolkit by 时运tk), the toolkit built around the Anima base model, where a booru-tag vocabulary and natural language coexist in the same prompt.
How the classification works
The node builds a tag → category index at runtime. It looks first for a sibling custom node, ComfyUI-Danbooru-Tag-Sorter-Node, and reads its tags_database/danbooru_tags.xlsx plus defaults_config.json. If that pack isn't installed, it falls back to a CSV bundled inside TK Toolkit itself and applies a built-in heuristic mapping (subcategory keywords like 头发/眼睛 → 角色特征词, 胸部/性器官 → 性征部位词, and so on), with anything it can't place landing in 未归类词.
That first parse is genuinely heavy - the database is over 200,000 rows. The node reads the xlsx XML directly rather than spinning up a full workbook, then writes the index to data/tag_category_index.cache so the next ComfyUI start is instant. Delete that file if you ever suspect it's stale; it self-invalidates when the source database changes anyway.
The inputs that matter
Twelve BOOLEAN switches, one per category, all off by default: 画师词, 背景词, 人物对象词, 角色特征词, 角色五官词, 角色部位词, 性征部位词, 服饰词, 动作词, 角色表情词, 镜头词, 未归类词. Tick the ones you want in the output. Nothing ticked means nothing gets extracted from the classification pass.
Then the filtering:
- natural_language - the prompt itself, shown in the UI as 统一 Prompt. It's a forced input socket, so wire it from a text node; it accepts a plain prompt or a Packer's
ALL_TAGS. - include_natural_language - on by default. Sentences the classifier can't identify ride along after the tags instead of being thrown away.
- filter_natural_language - apply the blacklists to those leftover sentences too.
- regex_blacklist - case-insensitive regex, e.g.
censor|watermark. - tag_blacklist - exact tag matches, comma or newline separated, case-insensitive. This is the one that kills
speech_bubblecleanly. - tag_bundle - optional
TAG_BUNDLEinput, for older workflows that already had a structured category pack wired up. You don't need both inputs; the single-prompt mode is the intended path now.
Each of the twelve categories also has its own weight input, 0.05–2.0 in 0.05 steps, defaulting to 1.0 - and 1.0 means no parentheses at all. Set 角色表情词 to 0.8 and you get (smile:0.8); if the incoming tag already carried a weight, the two multiply. Old workflows that restored the new widgets as 0 get treated as neutral 1.0 rather than emitting the (tag:0) that downstream encoders choke on.
Output is a single STRING, Tag String. Feed it to a CLIP text encode, or into TK 文本合并 if you're assembling a bigger prompt.
Set the weights to 1.0 and leave them
Here's my take, and it's grounded in how Anima works rather than in taste. Anima is LLM-encoded - a Qwen3-0.6B text encoder - and prompt weighting is disabled in the encoder path on those models. (smile:0.8) is not a gentle nudge there; it's punctuation handed to the encoder inside an instruction. Deleting the parentheses entirely is usually the better move. What you're paying for with this node is the classification: route the 镜头词 out and into a camera node, or drop 服饰词 while you're testing an outfit LoRA. That part is real and useful. The weights are a carryover from the SDXL world and mostly theatre on Anima.
Install and the one real gotcha
cd ComfyUI/custom_nodes
git clone https://github.com/Ararararararaki/comfyui-anima-toolkit
# restart ComfyUI (Python node changes always need a restart)
Or search TK Toolkit in ComfyUI Manager. aiohttp and requests are the only hard dependencies.
The gotcha is that sibling pack. Install ComfyUI-Danbooru-Tag-Sorter-Node next to TK Toolkit and classification follows that pack's curated database. Skip it and you're on the bundled CSV plus heuristics - still functional, but expect a fatter 未归类词 bucket. If everything is landing there, that's your signal the index didn't load. Also note the node only ever filters its own output; it never mutates the upstream TAG_BUNDLE or prompt.
Inputs (30)
| Name | Type | Default | Description |
|---|---|---|---|
| 画师词 | BOOLEAN | false | — |
| 背景词 | BOOLEAN | false | — |
| 人物对象词 | BOOLEAN | false | — |
| 角色特征词 | BOOLEAN | false | — |
| 角色五官词 | BOOLEAN | false | — |
| 角色部位词 | BOOLEAN | false | — |
| 性征部位词 | BOOLEAN | false | — |
| 服饰词 | BOOLEAN | false | — |
| 动作词 | BOOLEAN | false | — |
| 角色表情词 | BOOLEAN | false | — |
| 镜头词 | BOOLEAN | false | — |
| 未归类词 | BOOLEAN | false | — |
| tag_bundleopt | TAG_BUNDLE | — | |
| regex_blacklistopt | STRING | — | |
| tag_blacklistopt | STRING | — | |
| natural_languageopt | STRING | 统一输入:接入 Packer 的 ALL_TAGS 或普通 Prompt;已知 Danbooru Tag 会自动分类,未知段落可选择保留。 | |
| include_natural_languageopt | BOOLEAN | true | — |
| filter_natural_languageopt | BOOLEAN | true | — |
| 画师词_weightopt | FLOAT | 1.000.05–2 | 画师词 Tag 权重;1.0 保持原样,范围 0.05–2.0 |
| 背景词_weightopt | FLOAT | 1.000.05–2 | 背景词 Tag 权重;1.0 保持原样,范围 0.05–2.0 |
| 人物对象词_weightopt | FLOAT | 1.000.05–2 | 人物对象词 Tag 权重;1.0 保持原样,范围 0.05–2.0 |
| 角色特征词_weightopt | FLOAT | 1.000.05–2 | 角色特征词 Tag 权重;1.0 保持原样,范围 0.05–2.0 |
| 角色五官词_weightopt | FLOAT | 1.000.05–2 | 角色五官词 Tag 权重;1.0 保持原样,范围 0.05–2.0 |
| 角色部位词_weightopt | FLOAT | 1.000.05–2 | 角色部位词 Tag 权重;1.0 保持原样,范围 0.05–2.0 |
| 性征部位词_weightopt | FLOAT | 1.000.05–2 | 性征部位词 Tag 权重;1.0 保持原样,范围 0.05–2.0 |
| 服饰词_weightopt | FLOAT | 1.000.05–2 | 服饰词 Tag 权重;1.0 保持原样,范围 0.05–2.0 |
| 动作词_weightopt | FLOAT | 1.000.05–2 | 动作词 Tag 权重;1.0 保持原样,范围 0.05–2.0 |
| 角色表情词_weightopt | FLOAT | 1.000.05–2 | 角色表情词 Tag 权重;1.0 保持原样,范围 0.05–2.0 |
| 镜头词_weightopt | FLOAT | 1.000.05–2 | 镜头词 Tag 权重;1.0 保持原样,范围 0.05–2.0 |
| 未归类词_weightopt | FLOAT | 1.000.05–2 | 未归类词 Tag 权重;1.0 保持原样,范围 0.05–2.0 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| Tag String | STRING | — |