The Loop / While node repeats a set of steps. You can run the body once for each item in a list, a fixed number of times, or as long as a condition holds. When the loop finishes, execution continues once with the collected results.
What it does
- Runs a body sub-branch repeatedly, once per iteration.
- Exposes iteration variables inside the body so each pass can work on the current item.
- Collects the results and passes them on when the loop ends.
- Has a safety cap so a loop can never run away.
Two handles
The node has two output handles:
- body runs once per iteration. Connect the steps you want repeated here.
- after runs one time when the loop is done, carrying the accumulated output forward.
Loop types
- For each iterates over a collection or array you provide.
- Count repeats a fixed number of times.
- While keeps going as long as a value compares true against your condition.
Configuration reference
| Field | Applies to | What it does |
|---|---|---|
| Loop type | All | For each, Count, or While. Defaults to For each. |
| Content | For each | The collection or array to iterate over. Supports variable tags. |
| Iteration count | Count | How many times to repeat. Defaults to 3. |
| While input, comparison, value | While | The value checked each pass, the operator (equals, not equals, contains, greater than, less than), and the value to compare against. |
| Output mode | All | How per-iteration results are collected: accumulate, individual, concatenate, or last. Defaults to accumulate. |
| Max iterations | All | Safety cap on total iterations. Defaults to 100. |
| Continue on error | All | Keep iterating if one pass errors. On by default. |
Iteration variables
Inside the body branch you can reference the current pass with these tags from the loop node:
[[currentItem] from <loop-id>]the item for this pass[[currentIndex] from <loop-id>]the zero-based index[[totalCount] from <loop-id>]the number of iterations[[isFirst] from <loop-id>]and[[isLast] from <loop-id>]
After the loop, use [Input from <loop-id>] for the accumulated output.
Local or Cloud, and cost
Loop / While runs in both Local and Cloud modes and costs 0 credits. The steps inside the body still cost whatever those nodes cost, once per iteration, so watch the credit total on high-count loops. See Cost and usage tracking.
Worked example: process each scraped page
- Add a Web Scraper node that returns a list of pages.
- Add a Loop node, set type to For each, and set content to
[Input from firecrawl-1]. - From the body handle, add an AI Prompt node that summarizes
[[currentItem] from loop-1]. - From the after handle, send the accumulated summaries to an Output node.
Related
Was this helpful?
Contact us