PromptBackground
Background roulette — flip a prompt's background tags between colored, mono, or gone
- STRING
PromptBackground is a small tag-surgery node: give it a booru-style comma prompt and it rewrites the background tags in one of three ways - force a colored background, force black-and-white, or strip background tags out entirely. It's part of the Ranbooru pack's checkpoint-testing toolkit, and its natural slot is right after a Ranbooru node, before your CLIP Text Encode, when you want to A/B how a model handles color versus monochrome backgrounds without hand-editing prompts every run.
How it works
It splits your prompt on commas and compares each tag against two hardcoded lists: the colored ones (black_background, aqua_background, white_background, colored_background, and the rest of the standard booru set) and the mono ones (monochrome, greyscale, grayscale). Then it does exactly what the background_type menu says:
colored- removes any b&w tags and appends one randomly chosen colored background tag.b&w- removes colored tags and appendsmonochrome, greyscale, grayscale.remove- strips every tag on both lists, leaving the rest of the prompt alone.
The output is a single comma-joined STRING. Wire it wherever the cleaned prompt needs to go - usually into a CLIP Text Encode or another prompt node.
Two quirks worth knowing, both visible in the source. First, the recognition lists are fixed: if your background tag isn't one of the exact strings on the list, it sails through untouched. That's fine for booru output - this is built to clean booru output - but don't expect it to know about arbitrary background phrasing. Second, b&w appends all three mono tags at once, which is redundant and pushes the prompt length up; on CLIP-encoded models (the SDXL anime line) it works fine, just heavier than it needs to be. Colored is the one that actually feels like a roulette, since the color choice is random each run.
Inputs and outputs
prompt- STRING, your comma-separated prompt.background_type- enum:colored,b&w, orremove. Default isremove.
Output: STRING, the rewritten prompt.
Installing it
It ships with the Ranbooru pack: ComfyUI Manager, search "Ranbooru", or
cd ComfyUI/custom_nodes
git clone https://github.com/Inzaniak/comfyui-ranbooru
then restart. No requirements.txt to wrestle - the pack uses only ComfyUI's bundled Python packages - and no model downloads.
Common issues
Because it has no random state, this node is actually not one of the pack's always-rerun nodes - a prompt in gives a deterministic prompt out, except for the random color choice in colored mode. So if you set colored and the result keeps changing under you, that's the roulette doing its job. The real gotcha is expecting it to be a general background filter: it only knows the exact booru tag spellings. And on 2026 LLM-encoded checkpoints, remember the tag vocabulary still transfers (they understand the words), but on the CLIP-based anime models this node is aimed at, these tags are doing proper work.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | — | |
| background_type | COMBO | remove | 3 options: colored, b&w, remove |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |