Fetch Safebooru Sequential Top Tags
Pull prompt tags from Danbooru's SFW mirror
- combined_prompt
- current_post_tags
Same trick as its Danbooru twin, minus the explicit art. SafebooruSequentialTopTags walks the tags of the most-upvoted posts on safebooru.donmai.us - Danbooru's own G-rated mirror - and hands you a prompt-ready string, one seed at a time. If you like the idea of starting from real human-curated tags but don't want Danbooru's NSFW skew in your queue, this is the node you want.
Quick terminology trap first: this "Safebooru" is a subdomain of Danbooru, not the unrelated safebooru.org or any of the other sites that've borrowed the name. Don't go hunting for a different API; the node already points at the right host.
How it works
It's the same mechanism as DanbooruSequentialTopTags in this pack - literally the same code, different endpoint. It requests https://safebooru.donmai.us/posts.json?limit=200&tags=order:rank&page=N, which returns the top-scored posts on the SFW mirror in pages of 200, and caches them in a class-level queue. Your seed is the index into that list: the first run pins initial_seed, and abs(seed - initial_seed) picks the post. Step the seed by one, get the next post's tags. A guard modulo-wraps absurd seed jumps so it doesn't try to fetch hundreds of pages.
From each post it pulls whatever tag_string_* categories you've enabled, swaps underscores for spaces, comma-joins them, and prepends the result to your base_prompt. IS_CHANGED returns NaN, so the node always re-runs rather than caching.
Inputs and outputs
The ten inputs mirror the Danbooru node exactly, just with safebooru_username / safebooru_api_key instead. The ones worth your attention:
- seed - position in the top-post ranking. This is your whole control surface: +1, generate, +1, generate.
- include_general / include_artist / include_character / include_series / include_meta - which tag categories to keep. Artist on shifts style toward that artist; general on and the rest off is the default you'll probably keep.
- replace_underscores - leave on; the anime models learned tags with spaces (
blue eyes), not underscores. - base_prompt - a base you want merged with the fetched tags, appended after them.
The credentials are optional - anonymous requests work. Outputs are combined_prompt (tags + base_prompt, ready for a CLIPTextEncode) and current_post_tags (just the tags).
Install and gotchas
Install is shared with the pack: ComfyUI Manager, search "comfyui-safebooruTop", or:
cd ComfyUI/custom_nodes
git clone https://github.com/TZFC/comfyui-safebooruTop
then restart. The only dependency is requests - no models, no downloads.
The one genuine failure mode I hit testing this: the donmai.us API is behind a Cloudflare JS challenge, and scripted requests can get an HTML challenge page instead of JSON. The node's .json() call then fails, the exception is swallowed, and you silently get your base_prompt back with no tags - check the console for [Safebooru Node Error]. Retry or change network, since the challenge tends to be IP- or UA-dependent. Also note the tag queue is a class-level cache: it persists for the whole session, is shared between node instances, and resets on restart.
It's a small, young hobby pack (one star, no README), but the source is short and readable if you want to verify the behavior yourself. For SFW tag roulette on the same engine the anime models were trained on, it does exactly what it says.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| base_prompt | STRING | — | |
| safebooru_username | STRING | — | |
| safebooru_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 | — |