Handling n8n multiple inputs is a fundamental skill for building sophisticated workflows, allowing you to combine, compare, or enrich data from various sources into a single stream. The primary method is using the Merge node, which offers several modes like Append, Combine, and even SQL Query to join datasets structurally. For more flexible, ad-hoc data retrieval, you can use direct data referencing with expressions, such as $('node_name').all()
, to pull specific information from any previous node without altering the main data flow. Mastering both techniques is key to creating powerful, efficient, and scalable automations.
Why Would You Even Need Multiple Inputs?
As you move from simple, linear automations to more complex, multi-faceted workflows, you'll inevitably hit a point where one data stream just isn't enough. It's a natural evolution. Think about it: when do real-world processes ever rely on a single source of information? Almost never.
You might need to handle n8n multiple inputs to:
- Enrich Data: You have a list of new sign-ups from a webhook, but you need to pull company information from your CRM to personalize their onboarding sequence.
- Compare Datasets: You want to check if users in your database also exist in your mailing list and take action based on the result.
- Aggregate Reports: You need to pull sales figures from Stripe and website traffic from Google Analytics to create a consolidated daily report in a Slack message.
- Rejoin Branched Logic: After splitting your workflow with an
IF
orSwitch
node, you often need to bring the separate paths back together for a final common action, like sending a notification.
In all these cases, you're dealing with separate branches of data that need to interact. So, how do you make them talk to each other?
The Go-To Solution: The Mighty Merge Node
Your first and most powerful tool for this job is the Merge node. I like to think of it as the traffic controller of your n8n workflow. It stands at an intersection and intelligently directs different lanes of data, combining them into a single, orderly flow. It's designed specifically for handling n8n multiple inputs in a structured way.
One of the best things about the Merge node is that it waits for all its connected inputs to finish executing before it runs. This is crucial—it ensures you have all the necessary data before you try to combine it.
Understanding the Merge Modes
The real power of the Merge node lies in its different modes. While there are a few, you'll likely use these three the most:
- Append: This is the simplest mode. It just takes the items from Input 1, then stacks the items from Input 2 (and 3, and so on) right after them. Imagine taking two decks of cards and placing one on top of the other. No mixing, just a bigger stack.
- Combine (by Position): This mode pairs items based on their order. The first item from Input 1 is merged with the first item from Input 2, the second with the second, and so on. It's great when your two data sources are already perfectly sorted and aligned.
- Combine (by Matching Fields): This is where the magic happens. It's the equivalent of a
VLOOKUP
in Excel or aJOIN
in SQL. You tell the node to look at a specific field in both inputs (like an email address or a user ID) and combine the items where those fields match. This is incredibly powerful for data enrichment.
A Real-World Example: Enriching New Leads
Let's make this practical. Imagine new leads sign up via a form, and you get their name and company email. You also have a database (we'll simulate it with a Code node) that maps company domains to industries. Your goal is to send a welcome email that mentions their industry.
- Node 1 (Webhook/Code): Simulates a new lead. Output:
[{ "json": { "name": "Alex", "domain": "n8n.io" } }]
- Node 2 (Database/Code): Simulates your company data. Output:
[{ "json": { "company_domain": "n8n.io", "industry": "Automation Tech" } }]
- Merge Node: This is the hero. You connect both nodes to it.
- Mode:
Combine
- Combine By:
Matching Fields
- Input 1 Field:
domain
- Input 2 Field:
company_domain
- Mode:
- Send Email Node: The Merge node's output will be a single item containing the combined data:
{ "name": "Alex", "domain": "n8n.io", "industry": "Automation Tech" }
.
Now, your email can say, "Hi {{ $json.name }}! Welcome to the exciting world of {{ $json.industry }}!"
You've successfully enriched your data by merging two different inputs!
Beyond the Merge: Direct Data Referencing with Expressions
Now, here's where we get into more advanced territory. What if you don't need to combine entire datasets? What if you just need to pluck one tiny piece of information from another branch?
I’ve seen this trip people up in the community forums all the time. They'll have a workflow that calculates a total number of users in one branch, and in a completely separate branch, they just want to mention that number in a Slack message. Using a Merge node here would be overkill; it would combine all the user data with your Slack message data, creating a mess.
The elegant solution is to use an expression to reference the other node's data directly.
When to Use the Merge Node vs. Direct Expressions
Choosing the right tool for the job is what separates the pros from the beginners. Here’s a quick cheat sheet I use:
Feature | Merge Node | Direct Expressions $('...') |
---|---|---|
Best For | Structured data joining, combining entire datasets systematically. | Grabbing a single value or a few pieces of data from another branch. |
Workflow Clarity | High. The data flow is visually explicit on the canvas. | Lower. The dependency is hidden inside a node's parameter field. |
Complexity | Simple to configure for standard joins. | Can get complex with nested data and array indexes ([0] ). |
Example Use Case | Merging customer data with their order history before generating an invoice. | In a Slack message, mentioning the total_count from a database query node without merging all the data. |
To reference data, you use this syntax: {{ $('NODE_NAME').all()[0].json.propertyName }}
. Let's break that down:
$('NODE_NAME')
: Targets the node you want data from. Pro Tip: Name your nodes sensibly!$('Get_All_Users')
is a thousand times better than$('HTTP_Request1')
..all()
: This is the key part. It retrieves an array of all output items from that node.[0]
: Since.all()
gives you an array, you need to specify which item you want.[0]
gets the first one..json.propertyName
: This drills down into the JSON object to get the value you need.
Let’s be honest, this syntax can feel a bit like trial and error at first. But once you get the hang of it, it's an incredibly powerful tool for keeping your workflows clean when a full merge isn't necessary.
Final Thoughts: Structure or Flexibility?
Mastering n8n multiple inputs boils down to understanding this core trade-off. Do you need the robust, visual, and structured approach of the Merge node to combine entire datasets? Or do you need the flexible, lightweight power of an expression to quickly reference a piece of data from elsewhere?
Knowing the answer will not only make your workflows more efficient but will also elevate your automation game, allowing you to build solutions that truly mirror the complexity of your business processes. So go ahead, branch out, and start merging!