ComfyUI Node for Background Removal

withoutBG Remove Background is a ComfyUI custom node. It runs the open weights model in-process on your machine (free, no server), or the Pro Cloud API as an opt-in engine. It outputs an RGBA image and an alpha mask.

ComfyUI · Open weights in-process · RGBA + mask · Optional Pro engine

ComfyUI workflow: Load Image, withoutBG Remove Background, Save Image with a transparent result
A three-node workflow: Load Image → withoutBG Remove Background → Save Image.

Requirements#

DependencyNotes
ComfyUIAny recent version; install into its custom_nodes folder
Python 3.10+ComfyUI's own Python environment
withoutbg>=1.5.0Installed by requirements.txt; brings ONNX Runtime and OpenCV (headless)

Install#

Clone into ComfyUI's custom_nodes folder and install the requirements into ComfyUI's Python environment with uv:

Manual install

cd ComfyUI/custom_nodes
git clone https://github.com/withoutbg/withoutbg-comfyui
# activate ComfyUI's venv first, or add --python path/to/venv/bin/python
uv pip install -r withoutbg-comfyui/requirements.txt

No uv? pip install -r withoutbg-comfyui/requirements.txt with ComfyUI's Python works too. Once the first registry release is out, comfy node install withoutbg-comfyui (comfy-cli) does both steps.

Restart ComfyUI. The node is under image / withoutBG. The node is also published to the Comfy Registry (publisher withoutbg); once the first registry release is out, you can find it in ComfyUI-Manager by searching withoutBG.

An example workflow is in example_workflows/remove_background.json: Load Image, withoutBG Remove Background, Save Image.

The node: withoutBG Remove Background#

Inputs#

InputTypeNotes
imageIMAGE inputAny batch size
engineChoiceopen_weights (default, local, free) or pro (Cloud API)

Outputs#

OutputTypeNotes
imageIMAGERGBA: original colours plus the matte as alpha. Save with Save Image for a transparent PNG.
maskMASKThe alpha matte, foreground = 1

Batches are processed frame by frame with a progress bar, and you can interrupt the queue between frames.

Engines#

EngineRunsCostPrivacy
open_weightsIn-process ONNX on CPUFreeNever leaves your machine
prowithoutBG Cloud API1 credit per imageImage is sent to api.withoutbg.com

Open weights (default)#

The first run downloads the model from Hugging Face (withoutbg/withoutbg-openweights-onnx) into the Hugging Face cache. Set WITHOUTBG_MODEL_PATH to use a local model file. Runs on CPU. Same weights as the Python package, the Mac app and Docker.

Pro (optional)#

Pro is opt-in and needs an API key from your account. Each image costs 1 credit and is sent to the withoutBG API; open weights never leave your machine. Set the key in the environment before starting ComfyUI:

API key

export WITHOUTBG_API_KEY=...   # then start ComfyUI from this shell

The node has no key field on purpose. ComfyUI saves widget values in workflow files and embeds the workflow in every PNG it saves, so a pasted key would travel with anything you share.

Make a transparent PNG#

  1. Add a Load Image node and pick a photo.
  2. Add withoutBG Remove Background (image / withoutBG) and connect IMAGE to image.
  3. Connect the node's image output to Save Image. Queue the prompt.
  4. Use the mask output anywhere ComfyUI takes a MASK (inpainting, compositing, ControlNet preprocessing).

Troubleshooting#

SymptomFix
Node not found after installRestart ComfyUI. The node is under image / withoutBG; you can also double-click the canvas and search "withoutBG".
import cv2 fails (OpenCV conflict)withoutbg depends on opencv-python-headless. If ComfyUI already has opencv-python, the installer may add both. Reinstall one: uv pip uninstall opencv-python opencv-python-headless && uv pip install opencv-python-headless (or the same with pip, adding -y to uninstall)
onnxruntime missingThe package needs onnxruntime. Environments with onnxruntime-gpu keep working; the model still runs on CPU.
First run is slowThe model downloads from Hugging Face on first use. Later runs load it from the cache.
Pro engine failsCheck that WITHOUTBG_API_KEY is set in the shell ComfyUI was started from, and that the account has credits.

Model and license#

Node code: Apache 2.0. Model: the withoutBG Open Model License (Apache 2.0 for withoutBG portions; Meta DINOv3 License for the DINOv3 backbone weights). Built with DINOv3.

Common questions#

Does the ComfyUI node upload my images to the cloud?
Not with the default open_weights engine. The model runs in-process inside ComfyUI and images never leave your machine. Only if you switch the engine to pro (and set an API key) are images sent to api.withoutbg.com, at 1 credit per image.
Do I need a separate server or Docker?
No. Unlike the GIMP and Krita plugins, the ComfyUI node runs the model itself through the withoutbg Python package. There is no local server to start.
What does the node output?
Two outputs: image, an RGBA image with the original colours and the matte as alpha (save it with Save Image for a transparent PNG), and mask, the alpha matte with foreground = 1.
Does it process batches and video frames?
Yes. The image input accepts any batch size and each frame is processed in turn, with a progress bar and support for interrupting the queue.
Where does the model download to, and can I use a local file?
The first run downloads withoutbg/withoutbg-openweights-onnx from Hugging Face into the Hugging Face cache. Set WITHOUTBG_MODEL_PATH to use a local model file instead.
Does it need a GPU?
No. The open weights engine runs on CPU through ONNX Runtime. Environments that have onnxruntime-gpu installed keep working; the model still runs on CPU.
Why is there no API key field on the node?
ComfyUI saves widget values in workflow files and embeds the workflow in every PNG it saves, so a pasted key would travel with anything you share. Set WITHOUTBG_API_KEY in the environment before starting ComfyUI instead.