n8n Sub-Workflows: Reuse Logic with Execute Workflow

How to reuse logic in n8n with sub-workflows: define inputs, call them with Execute Sub-workflow, return output from the last node, and scope errors correctly.

Summarize this post with AI

A 16-minute read, or the key points in about 30 seconds, in the assistant you already use.

Opens in a new tab with the prompt filled in. Nothing passes through this site.

A workflow gets hard to change when the same five nodes are copied into four places. n8n's answer is a sub-workflow: one reusable workflow, called from a parent with the Execute Sub-workflow node, with a clear input and a clear output.

This guide shows how to set that up from n8n's official docs: the trigger, the input modes, how data comes back, and how errors are scoped between parent and child. I haven't built a new production automation for this post. The behaviour described here is the documented behaviour of the Execute Sub-workflow node and n8n's error-workflow settings.

Some links are affiliate links; they don't change your price.

Editorial cover showing an n8n Execute Workflow node calling a shared sub-workflow that fetches, transforms and validates data and returns a result

What is a sub-workflow in n8n?

A sub-workflow is an ordinary n8n workflow that another workflow can run on the same instance. You call it with the Execute Sub-workflow node. The child starts with the Execute Sub-workflow Trigger, also listed as "When Executed by Another Workflow".

n8n's docs describe the data path in one loop. The Execute Sub-workflow node in the parent passes data to the trigger of the child. The last node of the child sends data back to that same Execute Sub-workflow node in the parent.

That's the whole point. You get a reusable unit with a contract: inputs in, result out. It is a better place to put a repeated HTTP call, a cleanup script, or a shared "notify the team" path than copying nodes around. If you're new to the wider canvas, my n8n workflow examples post is the gallery this pattern sits under.

A sub-workflow is not a new server and it is not a webhook from the outside world. It runs on the same n8n host as the parent.

How do I create a sub-workflow?

You can start from a blank workflow, or you can extract one from a parent.

From a parent, the official docs give you two shortcuts. In the Execute Sub-workflow node, set Source to Database and From list, then choose "Create a sub-workflow". Or select the nodes you want to extract and use Sub-workflow conversion in the context menu.

In the child workflow:

  • Step 1: add the Execute Sub-workflow Trigger, if the shortcut didn't already add it.
  • Step 2: open Options, then Settings, and set "This workflow can be called by" to the callers you actually want. Don't leave a shared helper callable by everything on the instance if it can send mail or write data.
  • Step 3: set the trigger's Input data mode, which is the contract.
  • Step 4: build the rest of the nodes that do the work.
  • Step 5: save. n8n's docs are explicit: if the sub-workflow contains errors, the parent can't trigger it.
Infographic of how to create an n8n sub-workflow: add the trigger, restrict who can call it, define the input contract, build the nodes, then save a workflow with no errors
The child has to be valid before the parent can call it. Settings also control which workflows are allowed to call it.

Input data mode has three official options:

ModeWhat the parent must sendWhen to use it
Define using fields belowNamed fields and types, which then appear on the parent nodeAlmost always, for a stable contract
Define using JSON exampleA sample object that shows the expected items and typesWhen the shape is clearer as JSON than as a form
Accept all dataAnything, with no required fieldsOnly if the child is ready to handle missing values itself

I would start with "Define using fields below". The parent node then pulls in those fields automatically, which is the documented behaviour when Source is Database and From list.

If you later remove a requested field on the parent, the child receives null for it. You can also turn on "Attempt to convert types" if the parent might send a number as a string and you want n8n to try to coerce it.

"Accept all data" hides those input fields on the parent, because there is no contract to display. That's convenient for a prototype and sloppy for anything you'll reuse in six months.

How do I call the sub-workflow from the parent?

Open the parent, add the Execute Sub-workflow node, and point it at the child.

The Source field decides where the child definition comes from:

  • Database, From list or Workflow ID: the usual choice. The ID is the alphanumeric string after /workflow/ in the child's URL.
  • Local File: a path to a JSON workflow file on the host.
  • Parameter: workflow JSON pasted into the node.
  • URL: a URL that returns the workflow.

For almost every team workflow, use Database and pick the child from the list. Fill in the input fields the child requested, then save.

Two more official controls on the node change how it runs:

  • Mode: "Run once with all items" sends every input item into a single execution of the child. "Run once for each item" runs the child once per item, in turn.
  • Wait for Sub-Workflow Completion: when this is on, the parent waits for the child to finish before it continues. When it's off, the parent moves on without waiting.

Wait is the right default when the next parent node needs the child's output. Turn it off only when the child is a fire-and-forget side effect, such as a slow export you don't want to block on, and you have another way to watch the execution.

When both have run, the Execute Sub-workflow node has a "View sub-execution" link. The child's execution has a link back to the parent. Use those when something looks wrong, instead of guessing which run belongs to which caller.

Infographic of data passing between an n8n parent and sub-workflow: inputs from the Execute node, work in the child, last node returns output, with modes for all items or each item and an option to wait
The last node of the child is the return value. If you need that value in the parent, wait for the child to finish.

If you want example data while you build the child, n8n documents a path on n8n Cloud and registered Community plans. Set the child's Input data mode, turn "Save successful production executions" on in the child settings, run the parent once, then load data from that previous execution and pin it on the trigger. That's official, and it beats inventing sample JSON by hand.

How are errors scoped between parent and child?

By default, if the sub-workflow fails, the parent fails at the Execute Sub-workflow node. That's the behaviour you want when the child's result is required.

If you want the parent to keep going, use Continue on Fail on the Execute Sub-workflow node. The documented shape of the error item is a JSON object with an error field containing the error message. You can then branch on that field, the same way you would after a failed HTTP Request or a Code node.

Error workflows are a separate layer. In Workflow Settings, each workflow can name an Error Workflow that starts with the Error Trigger. The official "handle errors gracefully" docs are clear: you set this per workflow. A child's error-workflow setting is not inherited from the parent, and the parent's setting is not inherited from the child.

So if you need a Slack or email alert when the helper fails, set an error workflow on the child, on the parent, or on both, depending on who should be notified. Don't assume the parent alert will fire for a failure you swallowed with Continue on Fail. My n8n error handling guide is the deeper pass on retries, error workflows and alerts.

When should I use a sub-workflow, and when should I not?

Use a sub-workflow when the same logic will be called from more than one parent, or when a single parent is getting too long to debug. Shared work I would extract first: a notification path, a "normalise this payload" path, or a repeated API call with its own retries.

Keep the work in the parent when it's used once, when the mapping is still changing every hour, or when you'd have to pass almost the entire item through just to avoid a few nodes. A sub-workflow is a boundary. If the boundary is noisier than the duplication, wait.

Don't put a huge Code node in a child just to hide complexity. The child should still be readable. And don't use a sub-workflow as a substitute for credentials: those stay in n8n's credential store, not in the payload you pass down.

If you later turn the helper into part of an AI agent in n8n, the same "Call n8n Workflow Tool" path can use the fields you already defined on the trigger. That's a documented sibling of the Execute Sub-workflow node, and it's a good reason to define inputs properly from day one.

Comparison infographic of when to extract an n8n sub-workflow versus when to keep nodes in the parent, with rows for reuse, error scope, debugging and Best for
Extract a child when the logic is reused or the parent is hard to debug. Leave one-off mappings in the parent.

If you self-host, I still recommend a Hostinger KVM VPS for the machine that runs n8n, so the parent and the child share one reliable host.

Frequently asked questions

Where does the sub-workflow's output come from?▾
From the last node that runs in the child. That node's data is what the Execute Sub-workflow node in the parent receives. If you need a specific shape, end the child with a set or edit-fields node that returns only those fields.
Can a sub-workflow call another sub-workflow?▾
Yes, a child is a normal workflow, so it can contain its own Execute Sub-workflow node. Keep the chain short. Nested children are harder to trace, even with the view-execution links, and a failure can be harder to attribute.
What happens if I don't wait for the sub-workflow to finish?▾
The parent continues without the child's output. Use that only for side effects you don't need immediately. If the next node in the parent expects the child's data, leave "Wait for Sub-Workflow Completion" on.
Does the parent error workflow also cover the child?▾
Not automatically. Error workflows are set per workflow in Settings. Configure the child, the parent, or both. And if you turn on Continue on Fail in the parent, a child failure may never be a failed parent execution. The broader pattern is in this guide: [n8n error handling](/blog/n8n-error-handling)
Why can't the parent trigger the sub-workflow?▾
The official docs say the parent can't trigger a child that contains errors. Open the child, fix the broken node, and save. Also check "This workflow can be called by" in the child's settings, and confirm the parent is pointing at the right workflow ID.
Should I use a sub-workflow or a Code node?▾
Use a sub-workflow to reuse a flow, or to give a block its own error scope and execution history. Use a Code node for a small transform that isn't worth a separate workflow. If the code is copied into three parents, it's ready to become a child.

Define the child's inputs, keep the last node tidy, and decide on purpose whether a failure should stop the parent. That's the whole contract.

Once the helper is stable, call it from every parent that needs it, and stop copying the same five nodes.

Share