Nodes/ComfyUI-Ranbooru/Ranbooru Prompt
ComfyUI Node

Ranbooru Prompt

Let Ranbooru Prompt pull them from a real booru post

By liming123332·Created 10 months ago·Updated 9 months ago· 0
Ranbooru Prompt
    • positive
    • negative
    boorusafebooru
    tags
    remove_bad_tagstrue
    remove_tags
    change_backgroundDon't Change
    change_colorDon't Change
    shuffle_tagstrue
    change_dashfalse
    mix_promptfalse
    mix_amount2
    mature_ratingAll
    sorting_orderRandom
    limit_tags1.00
    max_tags100
    use_search_txtfalse
    search_file/tmp/ComfyUI/custom_nodes/ComfyUI-Ranbooru/user/search/tags_search.txt
    use_remove_txtfalse
    remove_file/tmp/ComfyUI/custom_nodes/ComfyUI-Ranbooru/user/remove/tags_remove.txt
    use_cachetrue
    api_key
    user_id
    post_id
    max_pages100
    chaos_modeNone
    chaos_amount0.50

    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, censored and even ai_generated / stable_diffusion (you can add your own via remove_tags),
    • applies your background/color strategy, truncates to your limits, and emits positive and negative strings.

    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. Default safebooru, 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/Explicit on rule34, the g/s/q/e single-letter scheme on danbooru/gelbooru). Keep it All and you will eventually get something awkward.
    • shuffle_tags and change_dash - shuffle randomizes tag order each run (that's your variety); change_dash swaps _ 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.

    CategoryRanbooru

    Inputs (25)

    NameTypeDefaultDescription
    booruCOMBOsafebooru9 options: safebooru, rule34, danbooru, gelbooru, aibooru, xbooru, +3
    tagsSTRING
    remove_bad_tagsBOOLEANtrue
    remove_tagsSTRING
    change_backgroundCOMBODon't Change4 options: Don't Change, Add Background, Remove Background, Remove All
    change_colorCOMBODon't Change4 options: Don't Change, Colored, Limited Palette, Monochrome
    shuffle_tagsBOOLEANtrue
    change_dashBOOLEANfalse
    mix_promptBOOLEANfalse
    mix_amountINT22–10
    mature_ratingCOMBOAll8 options: All, Safe, Questionable, Explicit, g, s, +2
    sorting_orderCOMBORandom3 options: Random, High Score, Low Score
    limit_tagsFLOAT1.000.05–1
    max_tagsINT1001–100
    use_search_txtBOOLEANfalse
    search_fileSTRING/tmp/ComfyUI/custom_nodes/ComfyUI-Ranbooru/user/search/tags_search.txt
    use_remove_txtBOOLEANfalse
    remove_fileSTRING/tmp/ComfyUI/custom_nodes/ComfyUI-Ranbooru/user/remove/tags_remove.txt
    use_cacheBOOLEANtrue
    api_keySTRING
    user_idSTRING
    post_idSTRING
    max_pagesINT1001–100
    chaos_modeCOMBONone3 options: None, Chaos, Less Chaos
    chaos_amountFLOAT0.500.1–1

    Outputs (2)

    NameTypeDescription
    positiveSTRING
    negativeSTRING