Overview
This lesson is part of the n8n AI Automation - Zero to Hero course, Section: 3. Deep Dive Concepts.
Watch the video above for the full tutorial, or read the written guide below.
What is the Loop Over Items node in n8n, and when do you need it?
The Loop Over Items node splits a dataset into batches and iterates over each batch, repeating a sequence of steps until all items are processed. Use it when you need controlled batch processing of large datasets, when an API enforces rate limits (such as 100 emails per second), or when a step-by-step process requires a Wait node between iterations. Without it, n8n fires every request simultaneously and gives you no throttle control.
How to use the Loop Over Items node in a real workflow
The Loop Over Items node exposes two output branches: a loop branch and a done branch. Every node you want to repeat connects into the loop branch, starting with a placeholder called Replace Me. After the last step in the loop, you wire that node's output back into the Loop Over Items node itself, closing the cycle. When all items are exhausted, execution exits through the done branch, where you can trigger downstream steps or attach a Do Nothing node to signal a clean end.
In the transcript workflow, a Gmail Trigger downloads email attachments with the Download Attachments option enabled and Simplify turned off. A Filter node checks that $json.binary exists, dropping emails with no attachments. A Split Out node on $binary then explodes the single email item into five separate binary items, one per attachment. These five items feed into Loop Over Items, which processes them one at a time.
Inside the loop branch, an HTTP node posts each binary file to a temporary hosting service (tempfiles.org) and returns a public URL. A Notion node then creates a database page in the sales task board, setting the email subject as the page title, a status property of To Do, and an image block populated with that temporary URL. A Wait node set to two seconds follows, preventing rate-limit errors on the Notion API before the output loops back into Loop Over Items. A critical fix covered in the transcript: instead of hardcoding the binary field name as attachment_0 (which breaks on iteration two), use the expression Object.keys($binary).first() to dynamically resolve whichever key is present on each iteration.
Key Takeaways
- The Loop Over Items node has two output branches: the loop branch (where repeated steps live) and the done branch (what runs after all items are processed).
- Even a batch size of 1 warrants Loop Over Items when you need a Wait node between requests; n8n's default per-item execution gives you no throttle control and will hit rate limits.
- The Split Out node on
$binaryis what converts a single multi-attachment email item into individual binary items that the loop can iterate over. - Dynamic binary field names require the expression
Object.keys($binary).first()rather than hardcoded keys likeattachment_0, which break on the second iteration. - Notion's API accepts images only by public URL, making a temporary upload step (via HTTP node to a hosting service) a required prerequisite before the Notion create-page call.
Related Lessons
- Lesson 11: How Branching works in n8n Workflows | Smart Automations with Multiple Paths
- Lesson 12: How to Use Merge Node in n8n | Combine Data Like a Pro
- Lesson 13: How to Use Set Node in n8n | Edit Fields Node | Add, Edit, Clean Data
- Lesson 14: How to Use Aggregate Node in n8n | Combine & Summarize Data
- Lesson 15: How to Use Remove Duplicates Node in n8n | Clean Your Data Fast
Next Steps
Continue your n8n journey with the full n8n AI Automation - Zero to Hero course.