Working with arrays and lists is one of the most common challenges in workflow automation. In n8n, data is processed as lists of items. Understanding how to split, iterate, batch, and recombine lists is critical for building efficient, enterprise-grade automations.
1. The n8n Data Model: List of Items
Unlike Zapier or Make, which treat arrays as single payloads that require custom loops, n8n inherently processes every node's output as an array of JSON objects (called "items"). By default, when a node receives 10 items, it runs once for each item. However, there are times you want to control this flow explicitly using loops.
2. Using the Loop Over Items Node
The Loop Over Items node is the standard way to run a group of nodes repeatedly for a list. Here is how you configure it:
- Input: Connect the array or list of objects to the Loop node.
- Batch Size: Determine how many items should be processed per iteration (typically 1 for sequential loops).
- Loop Branch: Connect the output port to the actions you want to run.
- Done Branch: Connect the done port to the nodes that should run after all iterations complete.
3. Code Node Custom Loop (JS)
For complex looping logic, using a Code Node with Javascript is extremely powerful. Here is a simple snippet to chunk an array of items into batches of 10:
const items = $input.all();
const batchSize = 10;
const batches = [];
for (let i = 0; i < items.length; i += batchSize) {
batches.push({
json: {
batch: items.slice(i, i + batchSize)
}
});
}
return batches;
💡 Best Practice: Always set a delay or rate-limiting step inside your loop if you are calling external APIs. Rapid requests without delays can trigger rate limits or IP bans from target services.