Merge Node Not Combining Data Correctly from Two Branches

Hi everyone, I’m having an issue with the Merge node in n8n. I’m trying to combine data from two different branches, but the output is not what I expect.
My workflow looks like this:
HTTP Request (Users) → Merge ← HTTP Request (Orders)
The first HTTP node returns user data, and the second returns order data. I’m trying to merge them so each user has their related order info, but instead I either get:
• Only data from one side
• Or mismatched items (wrong user with wrong order)
[
{ “user_id”: 1, “product”: “Shoes” },
{ “user_id”: 2, “product”: “Bag” }
]

Describe the problem/error/question

In the Merge node, I tried using “Merge by Index”, but I think that might be wrong. I also tried “Combine”, but the structure still doesn’t match what I expect.

What is the error message (if any)?

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hi @Keira_Becky

The issue is the Merge mode you’re using.

Merge by Index just matches items by position (0 with 0, 1 with 1), not by actual data. So if the order changes, you’ll get wrong matches.

You should use Merge by Key instead:
• Input 1 (Users): id
• Input 2 (Orders): user_id

This matches records correctly like this

user.id === order.user_id

Also make sure both fields are the same type I mean both numbers

2 Likes

Hi @Keira_Becky Are you using merge node combined? which is set to user_id as the matching field for both incoming inputs?

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.