# Loop
URL: /reference/blocks/system-loop
Type: reference
Description: Iterate over items, a fixed count, or while a condition is true
Keywords: loop, system/loop, system, block, workflow builder
`system/loop` — Iterate over items, a fixed count, or while a condition is true.

Where it appears [#where-it-appears]

The **Loop** block lives in the **Logic & control** group of the Workflow Builder.

Fields [#fields]

| Field           | Type                                   | Required | Default   | Description                                                                                                                                                                                                                                                                                     |
| --------------- | -------------------------------------- | -------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `loopType`      | select                                 | No       | `forEach` | How the loop decides when to stop. For Each iterates over an array, Repeat N Times runs a fixed count, While checks a condition before each iteration, and Do-While runs once before checking. The other fields shown depend on this choice. Options: `forEach`, `forLoop`, `while`, `doWhile`. |
| `items`         | text (multi-line, supports references) | Yes      | —         | The array to iterate over, one iteration per element. Accepts a literal JSON array or a \<PreviousStep.field> reference to an upstream array output.                                                                                                                                            |
| `iterations`    | text (supports references)             | No       | —         | Number of iterations to run. Accepts a fixed number or \<NodeName.field> reference.                                                                                                                                                                                                             |
| `condition`     | conditions                             | Yes      | —         | Boolean expression evaluated each iteration. Loop continues while truthy. Operators: ===, !==, >, \<, >=, \<=, !, &&, \|\|                                                                                                                                                                      |
| `maxIterations` | text                                   | No       | `100`     | Hard cap to prevent infinite loops. Loop exits once this count is reached even if the condition is still true.                                                                                                                                                                                  |
| `errorPolicy`   | select                                 | No       | `stop`    | What happens when an iteration throws an error. Stop halts the whole workflow; Continue lets execution proceed down the loop's exit path. Options: `stop`, `continue`.                                                                                                                          |

Inputs and outputs [#inputs-and-outputs]

Inputs are the configurable fields above. The block produces these outputs:

**Outputs**

Reference an output downstream with `<Loop.field>`.

| Name         | Type   | Description                    |
| ------------ | ------ | ------------------------------ |
| `items`      | array  | Items iterated over            |
| `iterations` | number | Number of iterations executed  |
| `results`    | array  | Array of all iteration results |

Example [#example]

A minimal configuration for this block:

```json
{
  "type": "system/loop",
  "config": {
    "loopType": "forEach",
    "items": "<PreviousStep.field>",
    "condition": "<PreviousStep.field>",
    "maxIterations": "100",
    "errorPolicy": "stop"
  }
}
```

Limits and failure modes [#limits-and-failure-modes]

* Required fields (`items`, `condition`) must be set, or the block fails validation before it runs.

Related [#related]

* [All workflow blocks](/reference/blocks)
* [Workflow Builder overview](/workflow-builder-overview)