DEV Community

Pirate Prentice
Pirate Prentice

Posted on

n8n Sub-Workflows: How to Call One Workflow from Another (Execute Workflow Node)

Most n8n tutorials show you how to build one workflow. But once your automations grow, you'll hit a wall: a single workflow becomes a 40-node maze that's impossible to debug or reuse.

The fix is sub-workflows — breaking your logic into small, focused workflows that call each other.

This guide covers:

  • What the Execute Workflow node does
  • When to split into sub-workflows (and when not to)
  • How to pass data in and get data back
  • A working example: modular lead processing
  • Error isolation between parent and child

What Is a Sub-Workflow?

A sub-workflow is any workflow triggered by another workflow using the Execute Workflow node (not a webhook, schedule, or manual trigger).

The parent workflow calls it, passes data in, waits for the result, and then continues.

Parent workflow
  → Execute Workflow node → Child workflow A
                          → returns processed data
  → Execute Workflow node → Child workflow B
                          → returns processed data
  → next step
Enter fullscreen mode Exit fullscreen mode

Sub-workflows are n8n's version of functions in code: named, reusable units of logic.


When to Use Sub-Workflows

Good use cases:

  • Logic you reuse across multiple workflows (e.g., "validate and format an email address")
  • A workflow that's grown past ~15–20 nodes and is hard to read
  • Steps with different error-handling requirements than the rest of your flow
  • Parallel tasks you want to reason about independently

Don't bother when:

  • The workflow is small and only used in one place
  • You'd just be splitting for splitting's sake — one extra layer of indirection with no benefit

Setting Up: The Execute Workflow Node

  1. Add an Execute Workflow node to your parent workflow
  2. Choose Workflow → select the child workflow by name
  3. Choose Source of input data → usually "Pass through all items from the parent"
  4. Activate the child workflow (it needs to be active to run, even in test mode)

The child workflow must start with a When Called by Another Workflow trigger (or Execute Workflow Trigger in older n8n versions) — not a webhook or cron.


Passing Data In

The parent workflow sends items to the child via the Execute Workflow node. The child receives them as its input.

Parent side:

[{ json: { leadEmail: "alice@example.com", source: "webform" } }]
Enter fullscreen mode Exit fullscreen mode

Child side — access via normal n8n expressions:

{{ $json.leadEmail }}
{{ $json.source }}
Enter fullscreen mode Exit fullscreen mode

You can reshape data before sending by adding a Set node before the Execute Workflow node.


Getting Data Back

The child workflow's last node output becomes the return value to the parent. Whatever data the child's final node emits, the Execute Workflow node in the parent receives it as its output.

Child workflow last node output:

// Code node in child
return [{
  json: {
    validated: true,
    normalizedEmail: $input.item.json.leadEmail.toLowerCase().trim(),
    score: 85,
  }
}];
Enter fullscreen mode Exit fullscreen mode

Parent workflow — use the result downstream:

{{ $json.normalizedEmail }}
{{ $json.score }}
Enter fullscreen mode Exit fullscreen mode

Clean, typed data flowing both directions.


Working Example: Modular Lead Processing

Without sub-workflows: one 30-node workflow handling everything.

With sub-workflows:

Parent: "Lead Router"

  1. Webhook trigger (receive lead)
  2. Execute Workflow → "Validate & Score Lead" (child A)
  3. IF node → score >= 70?
    • Yes → Execute Workflow → "Enrich Lead in CRM" (child B)
    • No → Execute Workflow → "Add to Nurture Sequence" (child C)
  4. Send Slack alert

Child A: "Validate & Score Lead"

  • Checks for valid email format
  • Checks for business domain (not gmail/yahoo)
  • Looks up company size (HTTP Request)
  • Returns { validated, score, normalizedEmail }

Child B: "Enrich Lead in CRM"

  • Writes to HubSpot / Sheets
  • Creates follow-up task
  • Returns { crmId, created }

Each child is testable in isolation. When something breaks, you know exactly which unit to look at.


Running Sub-Workflows in Parallel

By default, Execute Workflow runs synchronously (parent waits). To run multiple child workflows in parallel:

  1. Use Split in Batches to create separate item paths
  2. Wire multiple Execute Workflow nodes side by side
  3. Use the Merge node (mode: Combine) to collect all results

This is useful when you're enriching a list of records and want all calls to run simultaneously.


Error Isolation

One underrated benefit: sub-workflow errors don't automatically crash the parent.

The Execute Workflow node has an On Error setting:

  • Continue — if the child fails, the parent keeps going (item comes through without child output)
  • Stop and error — failure in child propagates up to parent

Use Continue when processing lists where individual failures are acceptable (e.g., enriching 100 leads — if 3 fail, you still want the other 97 to process).

Execute Workflow node settings:
  On Error: Continue (Ignore Error)
Enter fullscreen mode Exit fullscreen mode

Then check {{ $json.error }} downstream to catch failed items.


Free Workflow JSON

The n8n Workflow Starter Pack includes the Lead Capture → CRM → Welcome Email workflow in a structure that's ready to break into sub-workflows. Import-ready JSON with a setup guide.

n8n Workflow Starter Pack ($29 one-time)


Summary

Concept Detail
Trigger for child workflows "When Called by Another Workflow" node
Pass data in Via Execute Workflow node (parent items)
Get data back Child's last node output = parent's Execute Workflow output
Run in parallel Split In Batches + multiple Execute Workflow nodes + Merge
Error isolation Set "On Error: Continue" on Execute Workflow node

Sub-workflows are how you scale n8n from "this works" to "this is maintainable." Once you start using them, you'll refactor everything.


What's the longest single n8n workflow you've built? Drop a node count in the comments — curious where people hit the "I need to split this" threshold.

Top comments (1)

Collapse
 
pirateprentice profile image
Pirate Prentice

What's the longest single n8n workflow you've built before you hit the "I need to split this" wall? Drop a node count in the comments.

Also curious: are you using sub-workflows for parallel enrichment, approval gates, or something else entirely? Always looking for patterns I haven't seen yet.