Fetch Danbooru Sequential Top Tags
Turn a seed into a ready-made Danbooru prompt — no API key required
- combined_prompt
- current_post_tags
The name sounds like it needs an API key and a Terms of Service waiver. It doesn't. DanbooruSequentialTopTags walks the tags attached to Danbooru's highest-ranked posts, one seed at a time, and hands you a prompt ready to drop into a CLIPTextEncode. If you've ever wanted to generate from the tags real people actually curated onto good art - without typing a single tag yourself - this is the shortest path there is.
For anime SDXL models, tags are the interface. Illustrious, NoobAI, and (mostly) Pony were trained on Danbooru's exact vocabulary, so a correct tag beats a sentence for controlling pose, clothing, and character identity. Pulling human-curated tags off top-scored posts is a surprisingly strong starting prompt, which is exactly the trick this node exploits.
How it works
Under the hood it's simple. The node hits Danbooru's JSON API:
https://danbooru.donmai.us/posts.json?limit=200&tags=order:rank&page=N
order:rank returns posts sorted by score, 200 at a time. The clever part is the seed. Your first run records the seed as initial_seed, and every run after that computes actual_index = abs(seed - initial_seed). In other words, the seed is an index into that top-post list: bump it by one and you get the next post's tags. The node caches fetched posts in a class-level queue and pulls more pages as you advance, with a guard so a wild seed jump doesn't trigger hundreds of page fetches - it modulo-wraps instead. IS_CHANGED returns NaN, so the node always re-executes instead of caching.
Then it slices the post's tag_string_* fields according to your toggles, swaps underscores for spaces, joins everything with commas, and prepends it to your base_prompt.
The inputs that matter
Most of the ten inputs you'll leave alone. The ones you'll actually touch:
- seed - the position in Danbooru's top-post ranking. Step it by 1 for the next post; that's the whole "sequential" in the name.
- include_general / include_artist / include_character / include_series / include_meta - which tag categories to keep (general, artist, character, copyright/series, meta). Artist tags shift style toward that artist, which is a fun lever. General on, character/series/meta off is the sane default.
- replace_underscores - leave on. Danbooru tags like
blue_eyesbecomeblue eyes, which is how the anime models actually learned them. - base_prompt - prepended after the fetched tags. Since earlier tags get stronger attention, the fetched tags lead the prompt. Quality tags like
masterpieceend up at the back, which is fine.
danbooru_username and danbooru_api_key are optional - if both are filled they're appended as login/api_key params, but anonymous access works fine.
Two outputs: combined_prompt (fetched tags + your base_prompt) goes straight into a CLIPTextEncode's positive text; current_post_tags is the raw tags alone if you want to log or post-process them.
Installing it
ComfyUI Manager → search "comfyui-safebooruTop" (shown as "ComfyUI Safebooru Top Tags"), or the manual route:
cd ComfyUI/custom_nodes
git clone https://github.com/TZFC/comfyui-safebooruTop
Then restart ComfyUI. That's it - the only dependency is requests, which you already have. No models, no weights, no downloads.
Where people get burned
The one real gotcha I verified myself: Danbooru's API currently sits behind a Cloudflare JS challenge, and scripted requests can get back an HTML challenge page instead of JSON. The node does .json() on whatever it receives, so that silently fails - the except breaks, and you get your base_prompt back with no tags. Check the console for [Danbooru Node Error] and retry; the challenge is often IP- or UA-dependent, so it may just work for you.
Two quieter quirks. The tag cache is a class-level list that persists for the whole ComfyUI session, so multiple instances of the node share the same queue, and it resets on restart. And remember Danbooru is uncensored - "top posts" skew NSFW. That's the point for a lot of people, but if it isn't, the sibling node in this pack (SafebooruSequentialTopTags) pulls from the SFW mirror instead.
Also, one fair warning: this pack is tiny and brand new - a single-node hobby tool from user TZFC, one star, no README. It works, and the source is small enough to read in a minute if something surprises you. Just don't expect active maintenance.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| base_prompt | STRING | — | |
| danbooru_username | STRING | — | |
| danbooru_api_key | STRING | — | |
| include_general | BOOLEAN | true | — |
| include_artist | BOOLEAN | true | — |
| include_character | BOOLEAN | false | — |
| include_series | BOOLEAN | false | — |
| include_meta | BOOLEAN | false | — |
| replace_underscores | BOOLEAN | true | — |
| seed | INT | 00–18446744073709550000 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| combined_prompt | STRING | — |
| current_post_tags | STRING | — |