D: The Merge Node in n8n is a powerful tool that allows you to combine data from multiple sources or branches in your workflow. Whether you’re merging arrays, joining JSON objects, or aggregating API responses, this node can save you tons of time! π―
In this guide, weβll explore 10 real-world examples of how to use the Merge Node effectively. Letβs dive in!
πΉ 1. Basic Array Merging
Use Case: Combine two lists of products from different APIs.
Steps:
- Fetch data from API 1 (e.g., Shopify products).
- Fetch data from API 2 (e.g., WooCommerce products).
- Use the Merge Node in “Append” mode to combine both arrays.
Example Output:
[
{ "id": 1, "name": "T-Shirt", "source": "Shopify" },
{ "id": 2, "name": "Jeans", "source": "WooCommerce" }
]
πΉ 2. Merging JSON Objects by Key
Use Case: Combine user profiles from different databases.
Steps:
- Get user data from Database A (e.g., name & email).
- Get user data from Database B (e.g., address & phone).
- Use “Merge by Key” mode with
id
as the key.
Example Output:
{
"id": 101,
"name": "John Doe",
"email": "john@example.com",
"address": "123 Main St",
"phone": "+123456789"
}
πΉ 3. Aggregating Survey Responses
Use Case: Combine multiple survey responses into a single dataset.
Steps:
- Collect responses from Google Forms & Typeform.
- Use “Merge” in “Keep Key Matches” mode to align responses by
question_id
.
Example Output:
[
{ "question_id": "Q1", "answer": "Yes", "source": "Google Forms" },
{ "question_id": "Q1", "answer": "No", "source": "Typeform" }
]
πΉ 4. Combining CSV & API Data
Use Case: Enrich CSV data with live API information.
Steps:
- Load a CSV file with product SKUs.
- Fetch real-time pricing from a Pricing API.
- Merge using “Overwrite” mode to update prices.
Example Output:
{ "sku": "P100", "name": "Laptop", "price": "$999" }
πΉ 5. Merging Parallel Workflow Branches
Use Case: Run multiple API checks and combine results.
Steps:
- Branch 1: Check FedEx shipping status.
- Branch 2: Check UPS shipping status.
- Use “Append” to merge both into a single report.
Example Output:
[
{ "carrier": "FedEx", "status": "Delivered" },
{ "carrier": "UPS", "status": "In Transit" }
]
πΉ 6. Joining CRM & Email Marketing Data
Use Case: Sync customer data between HubSpot & Mailchimp.
Steps:
- Extract contacts from HubSpot.
- Fetch tags from Mailchimp.
- Merge by “email” field to enrich profiles.
Example Output:
{
"email": "user@example.com",
"name": "Alice",
"tags": ["Premium", "Newsletter"]
}
πΉ 7. Combining Multi-Page API Results
Use Case: Paginated API responses (e.g., Shopify orders).
Steps:
- Loop through pages using HTTP Request Node.
- Merge all pages into one array with “Append”.
Example Output:
[
{ "order_id": 1001, "total": "$50" },
{ "order_id": 1002, "total": "$75" }
]
πΉ 8. Merging Time-Series Data
Use Case: Combine daily sales reports.
Steps:
- Fetch yesterdayβs sales from DB.
- Fetch todayβs sales from API.
- Merge and sort by timestamp.
Example Output:
[
{ "date": "2023-10-01", "sales": 1200 },
{ "date": "2023-10-02", "sales": 1500 }
]
πΉ 9. Handling Conflicting Fields
Use Case: Priority-based data merging (e.g., “CRM overrides ERP”).
Steps:
- Set “Overwrite” mode.
- Define priority sources (e.g., Salesforce > SAP).
Example Output:
{ "client_id": "C100", "name": "Updated Name" }
πΉ 10. Dynamic Data Enrichment
Use Case: Add weather data to event locations.
Steps:
- Get event locations from Google Calendar.
- Fetch weather from OpenWeatherMap.
- Merge by “location” + “date”.
Example Output:
{
"event": "Conference",
"location": "Berlin",
"weather": "Sunny",
"temp": "22°C"
}
π BONUS TIP: Debugging Merges
- Use “Keep Key Matches” to avoid empty results.
- Add a “Function Node” to log merged data.
Final Thoughts
The Merge Node is a game-changer for data orchestration in n8n! π Whether you’re building ETL pipelines, CRM syncs, or multi-source reports, mastering this node will make your workflows 10x more powerful.
π‘ Pro Tip: Experiment with different merge modes (Append
, Merge by Key
, Overwrite
) to see which fits your use case best!
π Now it’s your turn! Try these examples and automate like a pro. Happy n8n-ing! π