How to Automatically Merge Duplicate HubSpot Contacts Using n8n (Free Workflow & Guide)

Keeping your CRM clean is a constant challenge—especially when duplicate contacts start piling up in HubSpot.

This tutorial shows how to use n8n to automatically detect and merge duplicate contacts, even if you’re on the free HubSpot plan where deduplication isn’t natively available.


Why this workflow?

  • Maintain accurate CRM data without manual clean-up

  • Avoid confusion caused by multiple records for the same person

  • Automate a task that can take hours when done manually


n8n Workflow Breakdown: Step-by-Step Guide

Prerequisite: Define a Unique Identifier

HubSpot usually detects duplicates via email, but this is often unreliable.

In this workflow, we use the LinkedIn Profile ID (linkedin_profile_id) as a unique property. You can adapt it to another unique field (phone number, internal ID, etc.) if needed.


Step 1: Start the Workflow (Manual Trigger)

Use the Manual Trigger to test the workflow before automating it (cron, webhook…).

Step 2: Retrieve All Contacts

The HubSpot node (Get All) fetches all contacts and returns the linkedin_profile_id property for further checks.

Step 3: Loop Through Each Contact

SplitInBatches processes one contact at a time to avoid overload.

Step 4: Add Delay (Rate Limiting)

Insert a Wait node (1s) to respect HubSpot’s API limits and prevent 429 errors.

Step 5: Check for LinkedIn Profile ID

Use an IF node to continue only if the contact has a linkedin_profile_id.

Step 6: Search for Potential Duplicates

Use HubSpot – Search to find contacts with the same LinkedIn ID. Limit results to 2 to confirm duplication.

Step 7: Extract IDs for Merge

A Code node extracts the IDs:

  • primaryObjectId (contact to keep)

  • objectIdToMerge (duplicate to merge)

Step 8: Validate Results

Another IF node ensures at least 2 results exist before proceeding.

Step 9: Prevent Wrong Merges

Check that primaryObjectId ≠ objectIdToMerge to avoid self-merges.

Step 10: Merge Contacts

An HTTP Request node calls the HubSpot API to merge the duplicate into the primary contact.


Demo video

Here’s a quick video walkthrough showing the workflow in action:


Result

After running the workflow, duplicate contacts are merged into a single record.

This keeps HubSpot data clean, reduces confusion for sales teams, and ensures marketing campaigns aren’t sending emails multiple times to the same person.


Full guide & resources

If you’d like a more detailed walkthrough, including screenshots and a downloadable file, you can find it here:

:backhand_index_pointing_right: Merge Duplicate HubSpot Contacts with n8n – Full Guide


Feedback welcome

This is the first version of the workflow, and it can be extended (e.g. custom rules for merging, logging actions into Google Sheets, etc.).

If you test it, let me know how it works for you and what improvements you’d add.

1 Like