Automatically Merge Duplicate Companies in HubSpot (Free n8n Workflow + Video + Downloadable Guide)

This guide shows you how to automate merging duplicate companies in HubSpot using n8n, even if you’re on a free HubSpot plan. No need to pay for the premium merge feature: this automation uses the HubSpot API to merge records automatically.

You can simply copy and paste the ready-to-use workflow and activate it instantly—no coding required—to optimize your CRM management in just a few minutes.

Hack’celeration: What the Experts Never Show You? We Give It to You.

Qonto logo, online banking solution for professionals.
Gymlib logo, fitness and wellness platform for companies.
Yousign logo, electronic signature service.
Spendesk logo, spend management platform.
Liligo logo, travel comparison tool.
Online restaurant reservation platform.

What the n8n Automation Does to Automatically Merge Duplicate Companies in HubSpot

Want to merge duplicate companies in HubSpot without paying for the premium feature? This n8n automation is designed to save you time by handling merges automatically via the HubSpot API.

Here’s how it works: follow the ready-to-use workflow, connect your HubSpot account, and in just a few clicks, you’ll automate duplicate detection and merging in your CRM.

Bonus: you can easily customize this setup to filter specific types of duplicates or extend it to other CRM objects (contacts, deals, etc.).

No more repetitive tasks or free plan limitations: with n8n, you automate HubSpot duplicate merges quickly, easily, and at no extra cost!

To make your life easier, the workflow you download is fully ready to use: every step of the workflow is detailed, with explanatory notes built directly into n8n. You’ll see exactly how each action works—everything is already mapped out for you.

In addition to the workflow, you get a complete video guide and a step-by-step tutorial to walk you through installation and setup. It’s super simple: import the workflow into n8n, follow the instructions, and automate in just a few minutes.

The goal: not just to quickly automate merging duplicate companies in HubSpot, but also to help you understand how it works and build your skills with n8n.

Video Tutorial – Merge Duplicate Companies in HubSpot with n8n

n8n Workflow Details: Step-by-Step Guide with Screenshots

LinkedIn Company ID field in HubSpot for identifying duplicate companies.

Prerequisite: Define a Unique Identifier to Detect Duplicates in HubSpot

Before using this automation, it’s essential to define a unique identifier that will allow you to detect duplicate companies in HubSpot. By default, HubSpot identifies duplicates based on the company domain (e.g., company.fr or company.io), but this method can be limited if a company uses multiple domains.

To ensure an effective merge, you should enrich your company records with a common, unique identifier. In our case, we use the company’s LinkedIn ID (linkedin-company-id), which is a reliable and unique identifier for each business.

  • Make sure each company record in HubSpot has a LinkedIn Company ID field.
  • If you haven’t done this yet, enrich your data by importing LinkedIn information using a third-party tool or this free downloadable workflow.
  • The workflow you download will automatically detect all companies sharing the same LinkedIn Company ID and merge them.

Important: This automation depends on having a reliable common field. If you don’t use LinkedIn, you can choose another unique field (e.g., Tax ID, internal ID, etc.) as long as it’s identical across duplicates.

Schedule Trigger in n8n set to run daily at midnight.

Step 1: Choose Your Trigger

The first step is to define when the workflow should run. In the provided workflow, we’ve included a Schedule Trigger that’s already set to execute daily at midnight.

This trigger allows the automation to search for and merge duplicate companies every night without any manual action. Of course, you can easily adjust the schedule to fit your needs: daily, weekly, or at a specific time of your choice.

Get Many Companies module in n8n with LinkedIn Company ID property included.

Step 2: Retrieve All Companies with Their LinkedIn Company ID

This step uses the HubSpot – Get Many Companies module in n8n. The goal is to fetch all companies from your CRM, making sure to include only those that have a LinkedIn Company ID, as outlined in the prerequisites above.

The module is configured with Return All = true to pull all company records without limitation. In the Company Properties To Include field, we add linkedin-company-id, which is the key property for identifying duplicates. Finally, the Include Value Only option is enabled to retrieve only the raw property values, simplifying the next steps of the workflow.

Loop Over Items module in n8n with Batch Size 1 for individual company processing.

Step 3: Loop Through Each Company (Loop Over Items)

Once all companies have been retrieved, the workflow uses a Loop Over Items module to process each company one by one. This helps control the flow and prevents sending large batches of requests that could overload the HubSpot API.

The Batch Size is set to 1, ensuring that each company is processed individually. This method keeps the automation smooth and stable, allowing you to check and merge duplicates step by step without risking errors from processing too much data at once.

Delay module in n8n with 1-second pause for API rate limit management.

Step 4: API Rate Limit Control (Adding a Delay)

To prevent overloading the HubSpot API, the workflow includes a Delay module configured with a 1-second delay between each request. This control is essential to respect the API rate limits set by HubSpot and to ensure the automation runs smoothly.

Even though the previous loop processes companies one by one (Batch Size = 1), it’s crucial to add this 1-second pause to avoid exceeding HubSpot’s allowed quota, which could cause errors or temporarily block API access.

IF module in n8n checking if LinkedIn Company ID is present.

Step 5: Check for the LinkedIn Company ID (IF Condition)

Before proceeding with the merge, the workflow includes a verification step using an IF module. This step checks whether the LinkedIn Company ID property exists for the company currently being processed (data retrieved from the previous loop).

The condition tests whether the LinkedIn Company ID field is not empty (not empty):

  • If TRUE: the condition is met, and the workflow continues to search for duplicates and proceed with merging.
  • If FALSE: no action is taken, and the workflow moves on to the next company in the loop.
HTTP Request module in n8n to search HubSpot companies by LinkedIn Company ID.

Step 6: Search Companies by LinkedIn Company ID (Custom API Call)

This is a crucial step: it identifies all duplicate companies based on the LinkedIn Company ID. To achieve this, we use an HTTP Request module to perform a custom query to the HubSpot API.

Why this approach? Currently, n8n does not offer a native HubSpot module that allows searching for companies using a custom property (like the LinkedIn Company ID). The native module only supports searches by domain, which isn’t sufficient for this use case.

We make an API call to the following endpoint: https://api.hubapi.com/crm/v3/objects/companies/search, authenticating the request using your HubSpot credentials.

➡️ Technical parameters:

  • Headers: Content-Type: application/json + Bearer Token (your HubSpot access token)
  • Method: POST
  • Body:
{
  "filterGroups": [
    {
      "filters": [
        {
          "propertyName": "linkedin_company_id",
          "operator": "EQ",
          "value": "{{ $json.properties.linkedin_company_id.value }}"
        }
      ]
    }
  ],
  "properties": [
    "name",
    "domain",
    "linkedin_company_id"
  ],
  "limit": 2
}

This body searches for all companies where the LinkedIn Company ID matches the current company being processed. The request returns key information: company name, domain, and LinkedIn ID.

Why set the limit to 2? This ensures we check if there are at least two companies with the same LinkedIn Company ID. If so, we identify a duplicate, and the workflow moves to the next step to merge them. This logic guarantees we only target true duplicates.

IF module in n8n checking for duplicate companies based on LinkedIn Company ID.

Step 7: Check for a Duplicate (IF Condition)

After retrieving the search results from the API, the workflow checks whether there is actually a duplicate to process. To do this, we use an IF module that checks the size of the returned results.

The condition verifies if the number of companies found ({{ $json.total }}) is less than or equal to 1:

  • If TRUE: this means no duplicate was detected (0 or only 1 company found). The workflow loops back to process the next company.
  • If FALSE: at least 2 companies were found (a confirmed duplicate). The workflow proceeds to the next step to merge them.

This verification is essential to avoid unnecessary or incorrect merge attempts when no duplicate is present.

HTTP Request in n8n for merging duplicate companies via HubSpot API.

Step 8: Merge the Companies (Custom API Call)

This is the final step: the workflow merges the companies identified as duplicates. Since HubSpot does not offer a native function in n8n to merge companies, we use an HTTP Request module to perform a custom API call.

The request is sent to the following endpoint: https://api.hubapi.com/crm/v3/objects/companies/merge, using your HubSpot credentials (Bearer Token in the headers).

➡️ The body used to perform the merge:

{
  "primaryObjectId": {{ $json.results[0].id }},
  "objectIdToMerge": {{ $json.results[1].id }}
}

This body tells HubSpot which company should remain (the primary company) and which one should be merged (the duplicate). This operation consolidates the data from both company records into a single record.

Once the merge is complete, the workflow automatically loops back to continue processing and checking the remaining companies until all records have been reviewed and merged if necessary.

Why Merging Duplicate Companies in HubSpot Is Crucial for Your CRM

Keeping a clean and well-organized HubSpot CRM is crucial for maintaining high data quality and maximizing the efficiency of your sales and marketing teams. Duplicate companies lead to errors, distort reports, and complicate customer relationships.

Problems caused by duplicates:

  • Inaccurate or conflicting data in your pipelines.
  • Risk of contacting the same client or prospect multiple times.
  • Less effective marketing campaigns due to segmentation errors.
  • Wasted time for your teams manually checking and fixing data.

Benefits of automatically merging duplicates in HubSpot:

  • Centralized key information for each company.
  • Better customer experience with accurate, up-to-date data.
  • Automated repetitive tasks to boost productivity.
  • Reliable analytics and reports to guide your sales strategy.

By automating the merging of duplicate companies in HubSpot, you ensure a high-performing CRM, save valuable time, and reduce the risk of errors. This automation is a powerful lever to improve your customer database management and accelerate your business growth.