---
version: "2026.1.0"
language: "en"
---
# Sub-flows

In Leapwork, you can build reusable automation components, known as **sub-flows**.

1. They enable you to design automation flows faster and significantly reduces maintenance time.

2. Sub-flows consist of existing building blocks that fulfil a repetitive step, for example, actions such as login and logout.

3. They can also be made up of other sub-flows.

Sub-flows can be added as many times as needed inside any automation flow.  
**Note** : The screenshots on this page use the **Elegance Design** , introduced in **2025.3**. If you are using an earlier version, your layout may look different.

## Creating and organizing sub-flows

Sub-flows can be created in two ways:

1. One way is to select building blocks that make up part of an existing automation flow:

   * Right-click on one of the selected elements.

   * Choose **Create Sub-flow** . This wraps all selected [building blocks](https://docs.leapwork.com/leapwork-flow/latest/building-blocks.md) and connectors into a new sub-flow, then prompts you to title it:

![image-20260225-131618.png](https://docs.leapwork.com/__attachments/a_2424515f49d716d20a6782cf23cce24e744e9e233a0cc77bd94efb3d949a4777/image-20260225-131618.png?cb=32a361931d2207d9fc46ad43038137a0)

In the example above, four building blocks form a new sub-flow named **Check total**:  
![image-20260225-131649.png](https://docs.leapwork.com/__attachments/a_cc00468e8b0f5b6582e2a411030d7b6e2bb706255957455a1588cb054452da35/image-20260225-131649.png?cb=a74d8cce5ef7118d08468be03a2d51f3)

2. The second way to create a sub-flow is to right-click anywhere in the flow tree-view and select the **Create sub-flow** option. This creates a new, empty sub-flow.

Sub-flows are shown with this icon in the flow-tree:  
![sub-flow icon](https://www.leapwork.com/hs-fs/hubfs/sub-flow%20icon.png?width=28&name=sub-flow%20icon.png)

You can drag sub-flows to any folder or below a specific flow. Since sub-flows are shared across all folders and flows in the tree view, organizing them in a dedicated folder makes them easier to find and clarifies their purpose.

## Adding sub-flows to a flow

To add a sub-flow to a flow:

1. Drag the sub-flow from the tree view onto the Leapwork Design Canvas.

2. Another way is to right-click the design canvas:

   * Select **Add new building block**.

   * Then choose the sub-flow from the **Sub-flows** category.

![image-20260109-115102.png](https://docs.leapwork.com/__attachments/a_24469c08fa99659ce386583388b591e1ddd847cd770bf4ef93ca8b3fc8710052/image-20260109-115102.png?cb=c0e5c1ee4403489ed4ce79c3edee1901)

## Editing a sub-flow

There are several instances where you would want to edit an existing sub-flow. For example,

* To add parameters and additional connectors

* To simply update the functionality inside the sub-flow

* To rename the sub-flow.

> When a sub-flow is updated, all dependents (flows using the sub-flow) are automatically updated. This is why using sub-flows is a great way to reduce the burden of maintenance.

To edit a sub-flow:

1. Either right-click the building block from the Design Canvas.

2. Select **Edit Sub-flow** or open it from the tree-view structure:

![https://www.leapwork.com/hs-fs/hubfs/image-png-Jun-22-2023-08-20-29-6899-PM.png?width=215&height=390&name=image-png-Jun-22-2023-08-20-29-6899-PM.png](https://www.leapwork.com/hs-fs/hubfs/image-png-Jun-22-2023-08-20-29-6899-PM.png?width=215&height=390&name=image-png-Jun-22-2023-08-20-29-6899-PM.png)

### Adding parameters

Adding parameters is a valuable feature of sub-flows. This increases the re-usability and allows for the sub-flows to be completely data driven.

Parameters are defined by a specific category of building blocks that can only be used inside sub-flows: [Value Input](https://docs.leapwork.com/leapwork-flow/latest/building-blocks/module-input-and-output/value-input.md) and [Value Output](https://docs.leapwork.com/leapwork-flow/latest/building-blocks/module-input-and-output/value-output.md).  
A sub-flow can have any number of input and output parameters. You can rename these parameters by changing the names of the Value Input and Value Output building blocks.

To change the name:

1. Double-click on the title of the building block.

2. Enter the new title.

In the example below, one input parameter is added to the sub-flow. The parameter is renamed **Value A**:  
![value input output](https://www.leapwork.com/hs-fs/hubfs/value%20input%20output.png?width=498&height=273&name=value%20input%20output.png)

When this sub-flow is added to a flow it will look like this:  
![sub-flow parameters](https://www.leapwork.com/hs-fs/hubfs/sub-flow%20parameters.png?width=216&name=sub-flow%20parameters.png)

### Connectors to sub-flows

The green connectors on a sub-flow are defined by a specific category of building blocks called [Execution Input](https://docs.leapwork.com/leapwork-flow/latest/building-blocks/module-input-and-output/execution-input.md) and [Execution Output](https://docs.leapwork.com/leapwork-flow/latest/building-blocks/module-input-and-output/execution-output.md). It is possible to have multiple connectors to and from a sub-flow, although typically only multiple **output connectors**are used.
> Multiple output connectors means the sub-flow can handle branching of the flow.

In the example below:

1. The sub-flow has two output connectors depending on the comparison operation. If the input value matches **200** , then the top green connector is triggered. Otherwise, the**Incorrect** green connector is triggered.

2. To make the sub-flow even more useful, the second green connector has been renamed to **No match**.

![sub-flow connectors](https://www.leapwork.com/hs-fs/hubfs/sub-flow%20connectors.png?width=550&height=298&name=sub-flow%20connectors.png)

When this sub-flow is used in a flow it looks like this:  
![branching flow with sub-flow](https://www.leapwork.com/hs-fs/hubfs/branching%20flow%20with%20sub-flow.png?width=533&height=278&name=branching%20flow%20with%20sub-flow.png)

### Renaming a Sub-flow

When a sub-flow is added to an automation flow, the sub-flow will by default have the given name of the sub-flow, i.e. the name shown in the tree-view.

**Note** : Whenever a sub-flow is changed, it is automatically reflected in the flows containing the sub-flow, *except* for changes made to the name of the sub-flow.

Once you have added a sub-flow to a flow, you are free to change the title of the specific instance of the sub-flow building block inside the flow. This means that if the name of the sub-flow is changed, i.e. by right-clicking in the tree-view and selecting **Rename**, then the title of the sub-flow block in the current flow will be changed.

Want to learn more about Sub-Flows? Follow [this resource](https://www.leapwork.com/learn/reusable-sub-flows) to begin.