SAM3 - Remove Background via Prompt
Isolate any subject from an image using a text prompt — just type what you want to keep (e.g. `character`, `dog`, `car`) and the workflow cuts it out and saves it as a PNG with a transparent background.
Try an example
About this workflow
This ComfyUI workflow isolates a subject from any image using a simple text prompt and exports a PNG with a transparent background. It links a LoadImage node to a SAM3Segment node, then into SaveImage. You type what you want to keep (for example, "character", "dog", or "red car"), and the SAM3Segment node generates a precise foreground mask and applies it as an alpha channel so everything else becomes transparent.
Technically, SAM3Segment performs prompt-aware segmentation over the input image, producing a binary mask for regions that best match the prompt. That mask is composited with the original RGB to produce an RGBA cutout. Because the node is designed to work well out of the box, most settings can remain at their defaults. The included MarkdownNote provides a quick reminder of the two essentials: connect an image and provide a clear prompt. SaveImage then writes the final cutout as a PNG, preserving transparency for downstream compositing in design, video, or web workflows.
Questions & answers
Use short, specific nouns with helpful attributes if needed: "red sedan", "white sneaker", "golden retriever". Avoid listing multiple different objects in one prompt—focus on the single subject you want to keep.
Start with the highest-resolution image you can and avoid heavy compression. Clear separation between subject and background also helps. If edges look soft, try a larger source image or crop the image (outside ComfyUI) to focus more on the subject before running the workflow.
It may select multiple instances if they all match the prompt, but results depend on the image. If you only want one instance, refine the prompt with distinguishing attributes (e.g., "front red car" vs. "cars") or run on a cropped version containing just the target subject.
The SaveImage node writes a PNG with an alpha channel. The background becomes transparent wherever the prompt-based mask excludes the image.