The Loop node iterates over an array and executes connected downstream nodes once per item.
Configuration
| Field | Description |
|---|---|
| Loop Over | The array to iterate — usually {{lastOutput.items}} |
| Condition | Optional expression to control when the loop continues |
How it works
Start → Fetch List → Loop → Process Item → (next step)
For each item in the array:
- The loop sets
loopItemto the current item andloopIndexto the position. - Downstream nodes execute with access to these values.
- After all items are processed, the loop output contains the collected results.
Accessing loop data
Inside nodes connected after the loop:
| Reference | Value |
|---|---|
{{loopItem}} | The current item in the iteration |
{{loopItem.name}} | A field on the current item |
{{loopIndex}} | Zero-based index of the current item |
Example prompt in an AI node inside a loop
Write a one-line social post for this product:
Name: {{loopItem.name}}
Description: {{loopItem.description}}
Example — process a list of contacts
Start (Manual)
→ HTTP Request (fetch contacts from API)
→ Loop (loop over {{lastOutput.contacts}})
→ AI Agent ("write a personalized greeting for {{loopItem.name}}")
→ Action (Gmail → Send Email to {{loopItem.email}})
Condition field
Use the condition to limit iterations:
loopIndex < 10
This processes only the first 10 items even if the array is longer.
Tips
- Make sure Loop Over points to an actual array. Check Execution Data on the upstream node.
- Keep per-item processing lightweight — large lists with AI nodes can be slow and costly.
- Use a Transform → Filter node before the loop to narrow the list.
- For very large datasets, consider batching with a Function node.