Loops and Array Operations
Working with many records: Split In Batches, Loop Over Items, array operations and performance tips.
In this chapter
Real automations rarely work with a single record — 500 leads, 1,000 products, 10,000 emails. In this chapter you will learn n8n's item-based execution model, how to break large lists into batches (Loop Over Items / Split In Batches), how to respect API quotas and how to keep memory-friendly patterns.
Topics
- Item-based execution model
- Split In Batches: chunking large lists
- Loop Over Items vs Function Item
- Aggregate / Item Lists nodes
- Rate limiting and respecting API quotas
- Memory and performance management
n8n's item-based execution model
n8n doesn't carry a single value, it carries an 'items' array. Each node runs once per item — so if 100 items hit an HTTP Request node, 100 requests fire, automatically. That's usually what you want. But for rate-limited APIs you sometimes need a controlled pace instead of sending everything at once. That's where Loop Over Items comes in.
Loop Over Items (Split In Batches)
Loop Over Items (formerly Split In Batches) breaks the incoming array into chunks of your chosen size and runs the connected nodes in sequence per chunk. 'Batch Size' is the key setting: 1 processes one at a time (slowest, safest); 10 processes ten at a time. The loop has two outputs — 'loop' (continue to next batch) and 'done' (proceed once all batches are processed). Don't forget to wire the body's end back to the loop — the most common bug.
Loop + Wait: rate limiting
Most APIs cap requests per second/minute (e.g. OpenAI ~60/min). Loop Over Items with Batch Size 10 + a Wait node (5 seconds) gives you ~120 requests/min — under the limit, safe. Hit the quota and you get 429s and rejected requests. Add 'Continue On Fail' + retry strategy and the system progresses without overloading.
Aggregate and Item Lists nodes
The opposite of Loop: collapsing many items into one. Aggregate joins all items into a single array field — useful for listing 100 orders in a single email body. Item Lists handles sort, filter, remove duplicates, group by — list operations. These two nodes save you a lot of work in summary/report flows.
Pagination: paging through large API responses
Most APIs return 100-500 records per call — you paginate to get the rest. The HTTP Request node's 'Pagination' option automates this: mode 'Update a Parameter in Each Request' and tell n8n how to advance the page or cursor parameter. Don't forget Max Pages or a 'while' condition — that's the only thing saving you from an infinite loop.
Memory and performance
n8n keeps all node outputs in memory for the duration of an execution. A 100K-item flow can eat 1-2 GB of RAM. Practical tips: use Loop Over Items (previous batch's data is dropped per batch), drop heavy fields early with Set, and when dealing with binary data (PDFs, images) only carry the binary per item when needed. In production, splitting heavy flows into sub-workflows (Execute Workflow) also lowers memory pressure.
This chapter's workflow (n8n editor view)