AI Help

How do I merge n8n branches by a record ID instead of item position?

Use Merge's matching-field option with a stable record key and define how unmatched and duplicate keys should behave.

Steps to follow

  1. Normalize the chosen ID consistently in both branches while retaining original values for inspection.
  2. Configure matching fields in the Merge node using the options available in your node version.
  3. Test reversed input order, missing IDs and duplicate IDs. Reconcile output counts before downstream updates.

Example in practice

Illustrative example. Branches returning contacts in different orders still join contact-17 to contact-17 through its ID.

Related AI help

Official guidance

n8n documentation