Nodes/ComfyUI-GTSuya-Nodes/Danbooru (Random)
ComfyUI Node

Danbooru (Random)

Pull a random post's tags and image, filtered by tag

By GTSuya-Studio·Created 3 years ago·Updated 4 months ago· 14
Danbooru (Random)
    • tags
    • img_url
    query_tag
    login
    api_key
    seed0

    Same idea as the plain Danbooru (ID) node - pull tags and an image URL off a Danbooru post - except you don't supply an ID, you supply a tag (or nothing) and get back a random post that matches. Want a random image tagged 1girl solo? Set tag_query to that and every run rolls a different post. Leave it blank and you're pulling from the entire board at random, which given Danbooru's size is a genuinely huge and varied pool.

    Where this earns a spot in a workflow: reference-image sourcing by concept. Say you're building a LoRA and want to eyeball how the community tags a particular pose or outfit before you start captioning your own dataset - query that tag, pull a handful of random matching posts, read the tag lists that come back. Or you're just looking for prompt inspiration in a specific style and don't want to manually browse the site.

    How it works

    Unlike the ID version, Random hits Danbooru's authenticated random-post endpoint, and Danbooru gates that behind an account. Per the pack README, the setup is: make a Danbooru account, request an API key from your account settings, and - this is the part people skip - explicitly grant that key permission to use posts:random. A generic API key without that permission checked won't work for this node. Once you've got login (your username) and the key, plug them in and the node is live.

    Inputs and outputs

    • query_tag - optional filter. Must be a real Danbooru tag; leave blank to pull from everything.
    • login - your Danbooru username.
    • api_key - your API key, with posts:random permission granted.
    • seed - controls which random post you land on; same seed, same post.

    Outputs: tags (the matched post's full tag string) and img_url (its image URL) - same shape as Danbooru (ID), and it pairs the same way with Load Image From URL from comfyui-art-venture to actually load the picture.

    Installing it

    ComfyUI Manager: search ComfyUI-GTSuya-Nodes, install, restart. Or by hand: cd ComfyUI/custom_nodes && git clone https://github.com/GTSuya-Studio/ComfyUI-Gtsuya-Nodes.git, restart ComfyUI. Then go set up the Danbooru account and API key separately - that part happens on Danbooru's site, not in ComfyUI.

    Where people get burned

    The number one failure mode is an API key that exists but doesn't have posts:random checked - the node will fail even though your login and key are both technically valid, because that specific permission is opt-in per key. Go back into your Danbooru account settings and confirm it's granted. Second: an unsupported or misspelled tag_query - if the tag doesn't exist on Danbooru exactly as typed, you get nothing back rather than a fuzzy match, so copy tags from the site instead of guessing at underscores and spelling. And the same caveat as the ID node applies here, doubled: Danbooru is uncensored, this endpoint samples from the whole board including explicit content, and an empty tag_query means you have zero control over what rating comes back - narrow the query if that matters to you.

    CategoryGtsuyaStudio/Downloads

    Inputs (4)

    NameTypeDefaultDescription
    query_tagSTRING
    loginSTRING
    api_keySTRING
    seedINT00–18446744073709550000

    Outputs (2)

    NameTypeDescription
    tagsSTRING
    img_urlSTRING