> ## Documentation Index
> Fetch the complete documentation index at: https://docs.comfy.org/llms.txt
> Use this file to discover all available pages before exploring further.

# SAM 3.1: Segment Anything in ComfyUI

> Learn how to use Meta's SAM 3.1 model in ComfyUI to segment objects in images and videos using text prompts

<Tip>
  <Tabs>
    <Tab title="Portable or self deployed users">
      Make sure your ComfyUI is updated.

      * [Download ComfyUI](https://www.comfy.org/download)
      * [Update Guide](/installation/update_comfyui)

      Workflows in this guide can be found in the [Workflow Templates](/interface/features/template).
      If you can't find them in the template, your ComfyUI may be outdated. (Desktop version's update will delay sometime)

      If nodes are missing when loading a workflow, possible reasons:

      1. You are not using the latest ComfyUI version (Nightly version)
      2. Some nodes failed to import at startup
    </Tab>

    <Tab title="Desktop or Cloud users">
      * The Desktop is base on ComfyUI stable release, it will auto-update when there is a new Desktop stable release available.
      * [Cloud](https://cloud.comfy.org) will update after ComfyUI stable release.

      So, if you find any core node missing in this document, it might be because the new core nodes have not yet been released in the latest stable version. Please wait for the next stable release.
    </Tab>
  </Tabs>
</Tip>

[SAM 3](https://ai.meta.com/sam3) (Segment Anything Model 3) is Meta's unified foundation model for promptable segmentation in images and videos. It can detect, segment, and track objects using text or visual prompts such as points, boxes, and masks. Compared to its predecessor [SAM 2](https://github.com/facebookresearch/sam2), SAM 3 introduces the ability to exhaustively segment all instances of an open-vocabulary concept specified by a short text phrase.

[SAM 3.1 Multiplex](https://github.com/facebookresearch/sam3) is the latest checkpoint release that introduces a shared-memory approach for joint multi-object tracking — significantly faster without sacrificing accuracy.

SAM 3.1 is natively supported in ComfyUI (PR [#13408](https://github.com/Comfy-Org/ComfyUI/pull/13408)), and the model weights are available under the [SAM License](https://github.com/facebookresearch/sam3/blob/main/LICENSE).

[SAM 3 GitHub](https://github.com/facebookresearch/sam3) | [Paper (arXiv)](https://arxiv.org/abs/2604.02296) | [🤗 Model Hub](https://huggingface.co/Comfy-Org/sam3.1)

<video controls width="100%">
  <source src="https://raw.githubusercontent.com/Comfy-Org/workflow_templates/refs/heads/main/output/utility_video_segment_sam3.mp4" type="video/mp4" />
</video>

SAM 3.1 segments and tracks objects across video frames based on text prompts. The example above shows the segmentation output with masks applied to the target objects throughout the video.

### Key strengths

* **Text-driven segmentation** — describe what to segment in natural language, no need for manual point/box annotations
* **Image and video support** — works on both single images and video sequences with tracking across frames
* **Multi-object support** — segment and track multiple objects simultaneously using comma-separated prompts
* **Open-vocabulary** — handles a vastly larger set of open-vocabulary concepts than prior works

> **Limitations:** The model has a max token limit of 32 for text prompts. For best results, keep prompts short and specific to the target object.

## SAM 3.1 Segment Workflows

### 1. Download Workflow

Update your ComfyUI to the latest version, then go to `Workflow` -> `Browse Templates` and find the SAM 3.1 workflows under the Utility category.

**Video Segmentation:**

<Card title="Download JSON Workflow File" icon="download" href="https://raw.githubusercontent.com/Comfy-Org/workflow_templates/refs/heads/main/templates/utility_video_segment_sam3.json">
  Download video workflow
</Card>

<Card title="Run on Comfy Cloud" icon="cloud" href="https://cloud.comfy.org/?template=utility_video_segment_sam3&utm_source=docs">
  Open in cloud
</Card>

**Image Segmentation:**

<Card title="Download JSON Workflow File" icon="download" href="https://raw.githubusercontent.com/Comfy-Org/workflow_templates/refs/heads/main/templates/utility_image_segment_sam3.json">
  Download image workflow
</Card>

<Card title="Run on Comfy Cloud" icon="cloud" href="https://cloud.comfy.org/?template=utility_image_segment_sam3&utm_source=docs">
  Open in cloud
</Card>

### 2. Download Models

The SAM 3.1 model is hosted on the [Comfy-Org SAM 3.1 model repository](https://huggingface.co/Comfy-Org/sam3.1).

* [sam3.1\_multiplex\_fp16.safetensors](https://huggingface.co/Comfy-Org/sam3.1/resolve/main/checkpoints/sam3.1_multiplex_fp16.safetensors)

Place it in the following directory structure:

```
📂 ComfyUI/
└── 📂 models/
    └── 📂 checkpoints/
        └── sam3.1_multiplex_fp16.safetensors
```

### 3. Using the Workflows

**Image Segmentation:**

* **Image** — Load an image via the `Load Image` node (place it in the ComfyUI `input/` folder)
* **Object Prompt** — A short text description of the object(s) to segment, e.g. `person`, `car`, `cat`
* The output is a mask applied to the image, with an RGBA preview showing the segmentation result

**Video Segmentation:**

* **Video** — Load a video via the `Load Video` node
* **Object Prompt** — Same as image, a short text prompt describing what to track and segment across frames
* The output provides masks and bounding boxes for each frame

**Prompt format:**

| Prompt             | Role                                                     |
| ------------------ | -------------------------------------------------------- |
| SAM3 object prompt | Short description of **what** to segment. Max 32 tokens. |

To prompt multiple subjects separately, separate with commas and use `:N` to specify the max amount of objects detected per prompt:
`eye:2, window panels:4`

<Card title="Learn about Subgraph" icon="book-open" href="/interface/features/subgraph">
  This workflow uses Subgraph nodes for modular processing. Check out the Subgraph documentation to learn how to customize and extend the workflow.
</Card>

## Additional Notes

* **Keep prompts short and specific** — the model has a 32-token limit per prompt
* **Multi-object detection** — use commas to separate different object types, and `:N` to cap detections per type
* **Segmentation masks** — the output mask can be used as input to other workflows (e.g., inpainting, background removal)
* **Update required** — make sure ComfyUI is updated to the latest version to access SAM 3.1 support
