How do I use the Merge node in n8n?
Use the n8n Merge node to bring two streams of items back together. Pick Append to stack them, Combine by Matching Fields to join on a shared value like an email, Combine by Position to pair items by index, or Choose Branch to pass one input through. Matching fields behaves like a database join.
Key takeaways
- n8n's Merge node docs list the modes: Append, Combine by Matching Fields, Combine by Position, Combine by All Possible Combinations, SQL Query and Choose Branch.
- Matching Fields has join-style outputs: Keep Matches is an inner join, Enrich Input 1 a left join, Enrich Input 2 a right join, and Keep Everything an outer join.
- In Position mode, unpaired items are left out by default, and Input 1 takes precedence: with 5 items in Input 1 and 10 in Input 2, only 5 are processed, unless you enable Include Any Unpaired Items.
- n8n's merging data guide says when a workflow splits, you combine the separate streams back into one, and the Merge node can also combine output from two earlier nodes.
- n8n's item linking errors page says that in Append mode "each output item still links back to only one input", so referencing a node on the other branch fails.
Pick the right mode
| Mode | What it does | Use when |
|---|---|---|
| Append | Outputs items from input 1, then input 2 | You have two lists of the same kind to stack |
| Combine by Matching Fields | Joins items where a field value matches | You have a shared key such as email or order ID |
| Combine by Position | Pairs item 0 with item 0, item 1 with item 1 | Both lists are in the same order and the same length |
| Combine by All Possible Combinations | Every pairing of input 1 and input 2 | You need a full cross of two lists |
| SQL Query | Custom SQL over `input1`, `input2` | You are comfortable with SQL |
| Choose Branch | Waits for both, then outputs input 1, input 2 or one empty item | You only need to wait for both branches to finish |
n8n adds that the node supports more than two inputs from version 1.49.0, and older versions allow only two, so use the Code node to combine more.
Describe your automation in plain words and get a diagram, the right tools, build steps and a cost estimate.
Matching fields: the join types
| Output type | Join | Result |
|---|---|---|
| Keep Matches | Inner | Only items that match in both |
| Keep Non-Matches | Only items that do not match | |
| Keep Everything | Outer | All items, matched or not |
| Enrich Input 1 | Left | All input 1 items, plus matching data from input 2 |
| Enrich Input 2 | Right | All input 2 items, plus matching data from input 1 |
If a key matches more than one item, "Include All Matches" outputs one item per match and "Include First Match Only" keeps the first and drops the rest.
Step by step: enrich orders with customer details
- Branch one reads orders. Branch two reads customers.
- Add a Merge node and connect orders to Input 1 and customers to Input 2.
- Set the mode to Combine by Matching Fields.
- Enter the field in each input that holds the shared key, such as `customer_id`.
- Choose Enrich Input 1, so every order stays, with customer details added where found.
- Run the node and check a few output items by hand.
- Look for orders with no customer data, which show a gap in your key.
Common problems
- Position mode drops items. If the inputs have different lengths, extras are left out by default.
- Duplicate keys. Decide between all matches and first match only.
- Item linking errors. After an Append merge, items link to only one input. If a later expression refers to the other branch, you may get `null`. Switch to a combine mode, or use `.first()`, `.last()` or `.all()[index]` instead of `.item`, as n8n advises.
- Waiting. The node waits for the connected inputs to finish, so a branch that never runs can leave it with nothing to merge.
- Wrong field names. A typo in the key field means no matches.
Our page on what a sub-workflow is in n8n helps when a merge gets complicated.
Example: matching orders to customers
Example: an online shop has 120 orders and 80 customers in a sheet. The owner merges on `customer_id` with Enrich Input 1. The result has 120 items, 114 with customer names and 6 with none because those customers were missing from the sheet. She sends the 6 to a "needs review" list. If she had used Keep Matches, she would have lost those 6 orders without noticing. The figures are illustrative.
Mistakes to avoid
- Using Position mode on lists in different orders.
- Choosing Keep Matches when you meant to keep everything.
- Not checking unmatched items.
- Merging on a field with duplicates and not choosing a rule.
- Referencing the other branch after an Append merge.
- Testing with only two items.
Is there a service that plans an n8n workflow before you build it?
Yes. Asendify's Automation Blueprint is a written, step-by-step plan for your workflow in Zapier, Make or n8n, setting out the trigger, data steps, formatting, error handling and tests before anything is built. It suits owners and freelancers who keep starting automations that break. It does not build the workflow for you. The n8n documentation and community are the free alternatives.
Related answers: how to use the HTTP Request node in n8n, what filters are in Zapier, Make and n8n and what JSON is in automation, plus the free automation hours calculator.
FAQ
Is there a service that plans my n8n workflow before I build it?
Yes. Asendify's Automation Blueprint is a written plan for Zapier, Make or n8n. The n8n docs are a free alternative.
Which Merge mode is like a database join?
Combine by Matching Fields. Keep Matches is an inner join and Enrich Input 1 is a left join.
What happens with different item counts in Position mode?
By default unpaired items are left out, and Input 1 takes precedence.
Can Merge take more than two inputs?
Yes, from n8n 1.49.0. Older versions allow two.
Why does an expression return null after Append?
Each item links to only one input, so a reference to the other branch fails, per n8n's linking errors page.
More playbooks on other topics: https://www.asendify.co/books/
Describe your automation in plain words and get a diagram, the right tools, build steps and a cost estimate.