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

# Snippets

> Reuse and share groups of nodes across workflows

Useful node patterns have a way of showing up in more than one workflow. Without a way to save and reuse them, you end up rebuilding the same logic every time: a particular chain of LLM and tool nodes, a data processing sequence, or a multi-step summarization pipeline.

Save a group of nodes as a reusable unit by turning them into a *snippet*: build the logic once, reuse it across workflows, and share it with your team to save others the effort of building the same thing from scratch.

You can also export snippets as DSL files to share them across workspaces.

## Create a Snippet

There are three ways to create a snippet:

* **From a workflow**

  Select the nodes you want to reuse, then right-click and choose **Create Snippet**.

  Their configurations are saved into the snippet. Any external variables they reference (outputs from nodes you didn't select, environment variables, and so on) automatically become the snippet's [Input Variables](#edit-a-snippet).

* **From scratch**

  In **Studio**, click **Snippets** at the top-right corner, then click **Create Snippet** > **Create from blank** to start with an empty canvas.

* **From a DSL file**

  In **Studio**, click **Snippets** at the top-right corner, then click **Create Snippet** > **Import DSL file** to import an existing snippet.

A snippet you create is shared with your workspace. What each member can do with it depends on their workspace role; see [Permissions](#permissions).

## Edit a Snippet

Building a snippet works much like building a standard workflow, with two differences.

First, a few nodes aren't available. Because a snippet plugs into a workflow instead of running on its own, it has no Start node (User Input or Triggers) and no end node (Output for Workflows, Answer for Chatflows). Knowledge Retrieval and Human Input aren't supported yet either.

Second, because a snippet has no Start node to collect input, you define **Input Variables** that specify what data it expects to receive, such as a variable from an upstream node. When a snippet is added to a workflow, these input variables become the connection points.

## Publish a Snippet

As you edit, your changes save automatically as a draft, so you can pick up where you left off next time. When the draft is ready, click **Publish** to make it usable. A workflow always uses the published version, never a draft.

Every publish is kept in the snippet's version history, where you can review or restore an earlier version.

## Add a Snippet to a Workflow

Right-click on the canvas, select **Add Node** > **Snippets**, then choose one to insert. Only published snippets appear here.

The snippet is added to your canvas as a copy. In the inserted nodes, set each input variable to the appropriate variable from your workflow, so they receive the data they expect.

Editing the original snippet later won't change workflows that already use it, and vice versa.

## Permissions

What you can do with a snippet depends on your workspace role:

| Action                                | Roles                                   |
| :------------------------------------ | :-------------------------------------- |
| View the snippet list                 | Owner, Admin, Editor                    |
| Create, edit, and publish snippets    | Owner, Admin, Editor                    |
| Delete snippets                       | Owner, Admin                            |
| Add a published snippet to a workflow | Anyone who can edit the target workflow |

Members with the Normal role don't see the snippet list.

<Tip>
  On Dify Enterprise, administrators can reassign these permissions to custom roles. [Contact sales](https://udify.app/chat/QuwcpW1oBNcfeL55) to learn more.
</Tip>
