Master Your Automations by Understanding n8n Input Data
To truly master n8n, you must first understand how it handles information. At its core, an n8n workflow processes input data by passing it between nodes in a specific, structured format. This data is an array of JSON objects, called “items,” which flow from a trigger or a preceding node into the current one. Grasping how to view, access, and manipulate this n8n input data
is the single most important skill for moving beyond simple automations and building complex, reliable workflows that solve real-world problems without causing headaches.
The Core Concept: What Exactly Is n8n Input Data?
Think of your n8n workflow as a high-tech factory assembly line. Each node is a different station on that line, and the input data is the set of components that arrive at each station to be worked on.
In n8n, these “components” are called items. A node receives an array of these items. Most of the time, what you care about is the json
property inside each item, which holds the key-value data you want to work with (like a customer’s name, an order ID, or a support ticket number). Sometimes, an item might also have a binary
property, which is where files, images, or PDFs live.
When you click on a node that has been executed, you can see this data structure in the output panel. You can switch between a user-friendly Table view and a raw JSON view. I personally spend most of my time in the JSON view because it gives me a perfect, unfiltered look at the exact data structure I’m dealing with. It’s the ground truth.
Accessing Your Data: Expressions vs. The Code Node
Okay, so the data is there. But how do you actually use it? How do you tell your Google Sheets node to use the ’email’ from the input to update a specific row? You have two primary methods.
The Easy Way: Using Expressions
For 90% of your daily tasks, expressions are your best friend. An expression is a small snippet of code you embed directly into a node’s parameter fields. They are your way of telling n8n, “Hey, don’t just use this fixed text I’m typing. Go grab a dynamic value from the input data.”
In any parameter field, you can start typing {{
to open the expression editor. The easiest way to get started is to use the variable selector—the little crosshair icon [+]
that appears next to the field. This opens a tree view of all the data from previous nodes, allowing you to click your way to the value you need.
For example, if you want to get the name from an input item, your expression might look like this:
{{ $json.name }}
Here, $json
is a handy shorthand that always refers to the json
object of the current item being processed. It’s simple, fast, and incredibly effective for most mapping tasks.
For More Power: The Code Node
Sometimes, simple mapping isn’t enough. What if you need to reformat a date, calculate a total, or loop through nested data? That’s when you bring in the heavy hitter: the Code node.
The Code node gives you a full JavaScript (or Python) environment to write custom logic. Instead of just accessing a single value, you can access the entire array of input items using the items
variable.
For instance, to get the name from the very first input item, you’d write:
const customerName = items[0].json.name;
From here, the sky’s the limit. You can transform data, merge objects, and return a completely new set of items to be passed to the next node. It offers ultimate flexibility when you need it.
Real-World Manipulation: Controlling the Data Flow
Now, here’s where it gets really interesting and where I see many new users get stuck. By default, if a node receives 10 items as input, it will execute its logic 10 times, once for each item. This is usually what you want, but sometimes it can cause major problems.
The “Too Many Executions” Problem: A Case Study
I recently saw a user in the community forum who was stuck on this exact issue. Their workflow did the following:
- Airtable Node 1: Upserted 47 records into a base.
- Airtable Node 2: Immediately tried to get all records from that same base to do a summary calculation.
The problem? The first node outputted 47 items. So, the second Airtable node executed 47 times! Instead of getting all records once, it fetched all records 47 times, resulting in a messy, duplicated, and huge dataset. So, how do we fix this?
Solution 1: The Simple Fix with the Limit Node
The easiest way to solve this is with the Limit
node. This node does exactly what its name suggests: it limits the number of items that get passed through.
By placing a Limit
node between the two Airtable nodes and setting its Limit parameter to 1
, you ensure that no matter how many items the first node outputs, the second node will only receive one. This forces it to execute only once. Problem solved!
Solution 2: The “Clean Slate” with a Set or Code Node
Using a Limit
node is great, but it still passes along the data from that one item. What if you want a completely fresh start?
You could use a Set
node after the Limit
node. In the Set
node, you can toggle on the “Keep Only Set” option and simply not define any values. This passes a single, empty item downstream, effectively wiping the slate clean.
For ultimate control, you can use a Code
node. You can write a tiny snippet that completely ignores all input and just returns a new, single item. This is powerful because you can create the exact data you need for the next step.
return [{ json: { status: 'Ready for the next step' } }];
Quick Reference: Common Ways to Access Input Data
To help you keep things straight, here’s a handy little table.
Variable / Method | What it Does | Common Use Case |
---|---|---|
{{ $json.key }} |
Accesses a value from the current item’s JSON. | Expressions (in any node) |
{{ $('Node Name').item.json.key }} |
Accesses data from a specific previous node. | Expressions (in any node) |
items |
An array of all input items to the node. | Code Node (for looping) |
$item(index) |
A helper to access data by its index in a list. | Expressions (advanced) |
A Final Word of Advice
Understanding n8n input data
is a journey from seeing it as a static result to seeing it as a dynamic flow you can direct and control. The key is to be deliberate. After you run a node, always check its output. Ask yourself: “Is this the number of items I expected? Is the structure what the next node needs?”
Don’t be afraid to sprinkle Limit
, Set
, and Code
nodes into your workflows. They aren’t just for complex logic; they are fundamental tools for directing the flow of data. Once you master that, you’ll be building automations you never thought possible.