1. The For Node (Collection Iteration)
The For node loops over an array of items (such as a paginated list of users, order items, or dynamic JSON arrays):
- Target Array Source: A dynamic expression referencing an array (e.g.
{{GetOrders.response.items}}). - Dual Handles:
L(Loop Body): Upper right handle connected to the subgraph executed for every iteration item.D(Done): Lower right handle connected to the downstream subgraph executed after all iterations complete.
- Exposed Loop Context Variables:
{{forNode.item}}: The current item in the iteration.{{forNode.index}}: The zero-based iteration index (0, 1, 2...).{{forNode.total}}: Total number of items in the source array.{{forNode.isFirst}}/{{forNode.isLast}}: Booleans indicating array boundaries.
2. The Repeat Node (Count-Based Loops)
The Repeat node runs a connected branch a predetermined number of times:
- Count Expression: Fixed number or dynamic expression (e.g.
5or{{flowVars.maxRetries}}). - Dual Handles:
L(Loop Body): Triggered once per count cycle.D(Done): Triggered once all repetitions finish.
- Exposed Variables:
{{repeatNode.iteration}}: One-based iteration number (1, 2, 3...).{{repeatNode.index}}: Zero-based index (0, 1, 2...).{{repeatNode.total}}: Total repeat target count.
3. The Collect Node (Result Aggregator)
When executing loop bodies, each iteration generates intermediate outputs. The Collect node gathers these outputs into a single consolidated structure:
- Collection Mode:
Append: Aggregates iteration outputs into an array ([result1, result2, result3]).Merge: Merges dictionary objects into a single cohesive payload.
- Source Expression: The specific property to gather (e.g.
{{ProcessItem.response.status}}).
4. Visual Expression Binding Picker
Users do not need to memorize or manually type binding syntax such as{{GetOrders.response.items}}. Every expression field across loop nodes includes a Visual Binding Picker:
- One-Click Trigger: Click the
{ }icon or the Browse All Bindings… chip. - 4 Unified Categories:
- ResponseBinding: Drill down into upstream predecessor HTTP or component nodes (response fields) with JSON property inspection.
- QMock: Insert synthetic mock data generators (
person.fullName,internet.email,datetime.now). - QPlugin: Integrate custom enterprise plugins and sandboxed functions.
- Variables: Access flow-level parameters and environment secrets.
preferArraySmart Filtering: When configuring aFornode’s items expression, the picker automatically highlights and surfaces array fields ([]).
5. Cyclic Return-Loop Visual Connection (n8n Benchmark)
Workflows featuring loops visually close the iteration loop directly on the canvas:- Top Return Port (
↺): TheForandRepeatnodes feature an iteration return port (↺) positioned along the top edge (left: 72%). - Non-Intersecting Upper Wire: The return wire sweeps from the final node of the loop body along the upper plane (
topY = min(startY, endY) - 38px) with an animated dashed pulse (↺ LOOP REPEAT), entering smoothly into the top port. - Zero Wire Crossing: Because loop body steps exit from the upper handle (
Lattop: 32%) and return via the top port, the iteration cycle stays entirely above the downstreamDone(Dattop: 68%) path, completely eliminating wire crossing. - DAG Safe: The backend sequential execution runner treats return wires purely visually, preventing circular graph deadlocks.
4. Enterprise Use Case: Batch Processing & Collection
Scenario
An integration flow queries a list of active accounts, iterates through each account to apply a status update, and aggregates all reference numbers into a final summary report:GET /accounts?status=active: Returns an array of 5 account objects.ForNode: Iterates over{{GetAccounts.response.items}}.- Loop Body (
POST /accounts/{id}/hold): Dispatches the update for{{forNode.item.accountNumber}}. CollectNode: Aggregates{{ApplyHold.response.referenceId}}into an array.- Done Handle (
POST /reports/batch-summary): Dispatches the collected list{{Collect.response.items}}to the reporting service.