Complete "Lesson 3: Looping Over Lists with SplitInBatches" first to unlock this lesson.Go to previous lesson

Introduction

In real n8n workflows you rarely have a single straight line of execution. More often you fork the flow: one branch queries your CRM, another fetches analytics, a third waits for a webhook from a customer. At some point you need to bring those parallel branches back together — and that is exactly what the Merge node is for. Understanding how to combine branches correctly prevents data loss, duplicate processing, and silent bugs that only show up in production.

This lesson covers the three main merge strategies in n8n: waiting for all inputs, merging by a matching key (SQL-style join), and appending (concatenating) all incoming items. Each strategy serves a different purpose, and picking the wrong one is one of the most common mistakes when building non-trivial automations.

a flow diagram showing one source node splitting into three parallel branches, each doing a different task, then all three feeding into a single Merge node that outputs one combined stream

How the Merge Node Works

The Merge node takes multiple input streams (Input 1, Input 2, optionally more) and produces a single output stream. It executes only when every connected input has delivered at least one item, which means it implicitly synchronizes the branches. This is the "wait" behavior: no matter how fast one branch finishes, the Merge node pauses until the slowest branch arrives.

You can also add a timeout in the node settings. If one branch never completes, the merge will eventually stop waiting and either drop the data or continue with whatever arrived. This matters for long-running workflows where one external API might hang.

Merge by Key (Join Behavior)

This is the closest equivalent to a SQL JOIN. You pick a field (e.g. `email` or `orderId`) that exists in both input streams, and the node pairs up items that share the same value. Items without a match are dropped by default, but you can configure the mode to behave like a LEFT JOIN (keep unmatched items from Input 1) or an outer join.

The result is one item per match, with fields from both inputs combined. The dropdown options are:

Append: concatenates all items from both inputs into a flat list, in order, without pairing. Use this when the branches produce independent records that should just be processed together later (for example, all contacts from Mailchimp and all contacts from HubSpot queued for a single deduplication step).

Merge By Key: pairs items on a shared field, like a database join. Use this when each item on one side logically relates to one item on the other side, such as matching an order record with its corresponding payment record.

Wait: the simplest mode — it does no transformation, just synchronizes timing. Output items follow Input 1's order, and Input 2's items are simply attached one-to-one by position. Use this only when you control both branches and know the order matches.

The Mode dropdown has these four options: Append, Merge By Key, Merge By Position, and Wait. Note that "Merge By Position" is the technical name for the simple wait-and-pair behavior — it pairs items by their index in the input array, which only works correctly when both branches have the same number of items in the same order.

Practical Example: Combining Order and Payment Data

Imagine Branch 1 pulls orders from a database, and Branch 2 pulls payment status from Stripe. Each branch produces items with an `orderId` field. You want one combined record per order.

json
{
"node": "Merge",
"type": "n8n-nodes-base.merge",
"parameters": {
"mode": "mergeByKey",
"joinMode": "inner",
"propertyName1": "orderId",
"propertyName2": "orderId"
}
}

With `joinMode` set to `inner`, only orders that exist in both branches end up in the output. If you switch to `left`, orders that have no payment record yet still flow downstream, marked as unmatched — useful for spotting missing payments.

Common Mistakes and Gotchas

The most frequent error is using "Merge By Position" when the two branches produce a different number of items. If Branch 1 returns 10 orders and Branch 2 returns only 7 payment records, 3 of the order items will either pair with `null` payment data or get silently dropped depending on settings. Always use "Merge By Key" when counts can differ.

Another gotcha: the Merge node does not deduplicate. If Branch 1 has the same email twice and Branch 2 once, you can get duplicate joined rows. Deduplication must happen before the merge, or with a separate node after.

Finally, remember that Merge waits for every connected input. If you forget to connect one input, the node will wait forever (or until timeout). Unconnected inputs are a common cause of workflows that hang in production.

Summary

The Merge node is the synchronization point of any multi-branch workflow. Use Append when you simply want to stack independent lists, Merge By Key when items on each side relate by a shared identifier, and Wait / Merge By Position only when both branches produce matched arrays of the same length. Always verify every input is connected, choose a join mode that matches your data integrity needs, and place deduplication outside the merge to avoid surprises.

a comparison diagram showing three merge modes side by side: Append (two lists stacked), Merge By Key (paired by shared field with arrows matching), and Merge By Position (paired by index 1-1, 2-2, 3-3)
Lesson practice

Lesson Checkpoint

Review what you learned and get feedback on your work.

0/7
01Which Merge node mode pairs items from two branches based on a shared field like `orderId`?
02What happens if you use Merge By Position but Branch 1 returns 10 items and Branch 2 returns only 7?
03Which Merge mode should you use to simply stack two independent lists of records into one combined list without pairing?
04Why might an n8n workflow hang indefinitely when using the Merge node?
05In the Merge By Key node, what does setting `joinMode` to `left` do?
06Which statement about the Merge node is TRUE?
07You have Branch 1 returning customer records and Branch 2 returning their latest support tickets. Each customer can have zero, one, or many tickets, and you want every customer to appear in the output even if they have no ticket. Which setup is correct?
Answered · 0/7
Lesson 4: Merging and Synchronizing Parallel Branches