Ranbooru Prompt
Let Ranbooru Prompt pull them from a real booru post
- positive
- negative
Ever sit staring at an empty prompt box wondering what a good "1girl" scene actually looks like in tags? This node is the answer to that specific laziness. Ranbooru Prompt searches a booru site's API for real posts matching your tags, grabs one post's tag list, and hands it back to you as a ready-to-use positive (and optional negative) prompt. No API key, no scraping setup, no database - it's a direct port of the popular sd-webui-ranbooru plugin that Forge users rave about, rebuilt as a single ComfyUI node. If you run any of the anime SDXL family (Illustrious, NoobAI, Pony) you already know those models think in Danbooru tags, so a node that hands you professionally-tagged posts is cheating in the good way.
How it works
The mechanism is simple and honest. You give it a search, it hits the chosen booru's JSON API, and pulls a page (or pages) of posts. Each site has its own scraper class - gelbooru, danbooru, rule34, e621, safebooru, konachan, yande.re, aibooru and xbooru are all supported. Then it:
- picks one post, by
sorting_order(a true random pick, or a score-weighted pick biased toward the top or bottom), - shuffles that post's tag list (order matters - earlier tags get stronger attention, so randomizing is the point),
- strips out a built-in blocklist of junk tags like
watermark,text,signature,censoredand evenai_generated/stable_diffusion(you can add your own viaremove_tags), - applies your background/color strategy, truncates to your limits, and emits
positiveandnegativestrings.
The output is just text, so the wiring is dead simple: Ranbooru Prompt → CLIPTextEncode → KSampler. Two STRING outputs, both clean.
The inputs that matter
There are a lot of knobs and most of them are "leave alone until you care." The ones a beginner actually touches:
booru- which site to search. Defaultsafebooru, which is conveniently the one you can point at work.tags- comma-separated, exactly like you'd type them into the site (1girl,long_hair). Required; an empty search is a coin flip.mature_rating- maps to each site's rating scheme (Safe/Questionable/Expliciton rule34, theg/s/q/esingle-letter scheme on danbooru/gelbooru). Keep itAlland you will eventually get something awkward.shuffle_tagsandchange_dash- shuffle randomizes tag order each run (that's your variety);change_dashswaps_for spaces, which is the "always replace underscores" rule from the prompting guides, automated.
The less obvious ones: sorting_order (Random / High Score / Low Score), limit_tags and max_tags to trim how many tags survive, and post_id to pin a specific post. mix_prompt blends tags from 2–10 posts, which is genuinely fun for pulling together a vibe from several images.
The negative prompt catch
Worth knowing up front: the negative output is empty string unless you turn on chaos_mode. Set it to Chaos or Less Chaos and the node splits your tag list - some tags go to the negative prompt, which is a quick way to fight against whatever composition you don't want without writing a word. Otherwise it's empty, so don't panic that you broke something.
Install
The easy way: ComfyUI Manager → search "ComfyUI-Ranbooru" → install → restart. Or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/liming123332/ComfyUI-Ranbooru
then restart ComfyUI. The only hard dependency is requests, which ComfyUI already ships, and the install script auto-installs the optional requests_cache - the node's use_cache defaults to on, so let that finish or you'll sit through the same API calls every single run. There are no model files to download; this thing only fetches tags, not images.
Troubleshooting
The README owns its real failure modes. Same prompt every run? Check three things: no post_id, sorting_order is Random, and shuffle_tags is on. Rule34 returns nothing? The node automatically retries without the default -animated exclusion, but some searches genuinely have no hits. Network errors like WinError 10054? That's the API resetting your connection - retry or switch networks; this is a live-HTTP node, so it's only as reliable as your connection to e621.
One quirk that'll bite you: when a search finds zero posts, the node returns a literal Chinese string ("未找到符合条件的帖子") as your positive prompt instead of an error. If your prompt suddenly becomes CJK, that's not a bug - your tags just matched nothing. Loosen the tags or lower max_pages, and remember mature_rating: All on safebooru is the most forgiving setting for a first run.
Inputs (25)
| Name | Type | Default | Description |
|---|---|---|---|
| booru | COMBO | safebooru | 9 options: safebooru, rule34, danbooru, gelbooru, aibooru, xbooru, +3 |
| tags | STRING | — | |
| remove_bad_tags | BOOLEAN | true | — |
| remove_tags | STRING | — | |
| change_background | COMBO | Don't Change | 4 options: Don't Change, Add Background, Remove Background, Remove All |
| change_color | COMBO | Don't Change | 4 options: Don't Change, Colored, Limited Palette, Monochrome |
| shuffle_tags | BOOLEAN | true | — |
| change_dash | BOOLEAN | false | — |
| mix_prompt | BOOLEAN | false | — |
| mix_amount | INT | 22–10 | — |
| mature_rating | COMBO | All | 8 options: All, Safe, Questionable, Explicit, g, s, +2 |
| sorting_order | COMBO | Random | 3 options: Random, High Score, Low Score |
| limit_tags | FLOAT | 1.000.05–1 | — |
| max_tags | INT | 1001–100 | — |
| use_search_txt | BOOLEAN | false | — |
| search_file | STRING | /tmp/ComfyUI/custom_nodes/ComfyUI-Ranbooru/user/search/tags_search.txt | — |
| use_remove_txt | BOOLEAN | false | — |
| remove_file | STRING | /tmp/ComfyUI/custom_nodes/ComfyUI-Ranbooru/user/remove/tags_remove.txt | — |
| use_cache | BOOLEAN | true | — |
| api_key | STRING | — | |
| user_id | STRING | — | |
| post_id | STRING | — | |
| max_pages | INT | 1001–100 | — |
| chaos_mode | COMBO | None | 3 options: None, Chaos, Less Chaos |
| chaos_amount | FLOAT | 0.500.1–1 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| positive | STRING | — |
| negative | STRING | — |