Nodes/ComfyUI-RecraftAI/RecraftAI Background Replacer
ComfyUI Node

RecraftAI Background Replacer

Swap the scene behind a subject in one node — subject stays put, world changes

By recraft-ai·Created 2 years ago·Updated about a year ago· 73
RecraftAI Background Replacer
  • client
  • image
  • image
prompt
style
substyle
seed0

This is the background remover's useful older sibling. Where the remover just deletes the background, this node detects the subject, keeps it, and generates a brand new background around it from a text prompt. "This portrait was shot in a studio" becomes "this portrait, but they're standing in a neon Tokyo alley at midnight." The subject stays put and pixel-identical; only the world behind them changes.

That last part is the reason this node still has a job in 2026. The community has largely moved background-swapping and object-editing jobs over to whole-frame instruction models like Flux Kontext and Qwen-Image-Edit - but those models re-render the entire image, so the subject comes back close but not identical, and the drift compounds across a chain of edits. This node keeps the subject exactly as it was and only regenerates the background, which is the classic "keep the rest of the image alone" case done server-side. If you've ever had a product shot or a client portrait where the subject cannot be altered, this is the honest tool for the job.

The inputs that matter

Required: client, image, and prompt. The prompt describes the new background - "a sunlit European street," "an abstract gradient," "a winter forest." It doesn't need to describe the subject; the node keeps it automatically.

Optional: style and substyle - the same pair as the rest of the pack (realistic_image, digital_illustration, any plus seventeen substyles like hdr, natural_light, studio_portrait, pixel_art). These shape the generated background's look, so matching them to the subject's own lighting saves you from obvious mismatches - no hard-flash background behind a soft, natural-light portrait. seed rounds it out for reproducible runs.

How it works

The node serializes your image to PNG, multipart-POSTs it with the prompt, style, and substyle to Recraft's /images/replaceBackground endpoint, downloads the returned image, and converts it back into a ComfyUI IMAGE tensor on the image output. Subject detection is automatic and happens server-side - you don't supply a mask or tell it what the subject is. Same client, same key, same billing as everything else in the pack.

One workflow worth stealing: run the Background Remover first, composite the cutout onto a solid color, and then replace the background. It sounds redundant, but it gives you a predictable foreground to judge the generated scene against before you commit.

Installing it

ComfyUI Manager: search "RecraftAI", install ComfyUI-RecraftAI, restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/recraft-ai/ComfyUI-RecraftAI
cd ComfyUI-RecraftAI && pip install -r requirements.txt

Windows portable: .\python_embeded\python.exe -m pip install -r ComfyUI\custom_nodes\ComfyUI-RecraftAI\requirements.txt. Only requests, torch, Pillow, numpy - no models to download, no VRAM used. You'll need an API key from recraft.ai/profile/api.

Where people get burned

  • Empty prompt = hard fail. The node raises Prompt is required. The prompt is the entire generation instruction here; there's no default scene.
  • Ambiguous subjects. If the image has no single clear subject, "detect and replace" gets dicey - a cluttered desk photo won't know which object is the keeper.
  • Lighting mismatch. The background is generated fresh, so it won't automatically match the subject's light source. Nudge substyle toward the subject's lighting (natural_light, hard_flash, studio_portrait) rather than hoping the model infers it.
  • Cost. Every swap is a paid API call. This one's easy to burn through if you're iterating on the prompt.
CategoryRecraftAI

Inputs (6)

NameTypeDefaultDescription
clientRECRAFTCLIENT
imageIMAGE
promptSTRING
styleoptCOMBO4 options: , any, realistic_image, digital_illustration
substyleoptCOMBO17 options: , b_and_w, hard_flash, hdr, natural_light, studio_portrait, +11
seedoptINT00–2147483647

Outputs (1)

NameTypeDescription
imageIMAGE