> ## Documentation Index
> Fetch the complete documentation index at: https://docs.comfy.org/llms.txt
> Use this file to discover all available pages before exploring further.

# StartLoop - ComfyUI Built-in Node Documentation

> The Start Loop node starts a looping structure inside a workflow.

The Start Loop node starts a looping structure inside a workflow. It runs the connected loop body one time per iteration and can count iterations in three ways: a fixed number of repetitions (simple), a numeric index range (For), or one pass per item in a list (List). Each pass exposes the current index, first/last flags, and an optional carried value that can be passed from one iteration to the next.

## Inputs

### Common Inputs

| Parameter                 | Description                                                                                                               | Data Type          | Required | Range                                 |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------ | -------- | ------------------------------------- |
| `mode`                    | The loop iteration mode (default: "simple"). The selected mode determines which additional parameters are shown.          | DYNAMIC\_COMBO     | Yes      | `"simple"`<br />`"For"`<br />`"List"` |
| `cache_iterations`        | Reuse unchanged iteration results from previous executions. Disable to execute every iteration again. Default: false.     | BOOLEAN            | Yes      | true<br />false                       |
| `parent_iteration`        | Connect iteration\_index from an outer Start Loop to nest this loop. This input is force-input only (a link is required). | INT                | No       | Any integer                           |
| `initial_iteration_value` | Value exposed as current\_iteration\_value on the first iteration.                                                        | ANY (type-matched) | No       | Any value                             |

### Simple Mode Inputs

| Parameter        | Description                                           | Data Type | Required | Range     |
| ---------------- | ----------------------------------------------------- | --------- | -------- | --------- |
| `num_iterations` | Number of times to execute the loop body. Default: 4. | INT       | Yes      | Minimum 0 |

### For Mode Inputs

| Parameter               | Description                                                                      | Data Type | Required | Range                      |
| ----------------------- | -------------------------------------------------------------------------------- | --------- | -------- | -------------------------- |
| `start_iteration_index` | Index of the first iteration when using For loop mode. Default: 0.               | INT       | Yes      | Any integer                |
| `max_iteration`         | The exclusive stopping value for iteration\_index in For mode. Default: 4.       | INT       | Yes      | Maximum 0xffffffffffffffff |
| `step`                  | The index step size between each iteration when using For loop mode. Default: 1. | INT       | Yes      | Minimum 1                  |

### List Mode Inputs

| Parameter | Description                                                               | Data Type                    | Required | Range    |
| --------- | ------------------------------------------------------------------------- | ---------------------------- | -------- | -------- |
| `list`    | List of items the loop iterates on. The loop body executes once per item. | ANY (type-matched list item) | Yes      | Any list |

Notes:

* Only the parameters belonging to the currently selected `mode` are shown and used.
* In Simple mode, the iteration indices run from 0 up to `num_iterations` minus 1. In For mode, indices run from `start_iteration_index` up to (but not including) `max_iteration`, increasing by `step`. In List mode, one iteration runs per item in `list`.
* `step` must not be 0; a value of 0 raises an error. Values below 1 are not allowed.
* If the computed number of iterations is zero, the `is_last` output is reported as true and the loop body does not run.

## Outputs

| Output Name               | Description                                                                                                                                                             | Data Type          |
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ |
| `iteration_index`         | Index of the current loop iteration.                                                                                                                                    | INT                |
| `is_first`                | True during the first iteration of the loop.                                                                                                                            | BOOLEAN            |
| `is_last`                 | True during the last iteration of the loop.                                                                                                                             | BOOLEAN            |
| `list_item`               | Current item from the list when using List mode. None in Simple and For modes.                                                                                          | ANY (type-matched) |
| `current_iteration_value` | Loop-carried value for the current iteration: initial\_iteration\_value on the first iteration, then next\_iteration\_value from End Loop on each subsequent iteration. | ANY (type-matched) |

> This documentation was AI-generated. If you find any errors or have suggestions for improvement, please feel free to contribute! [Edit on GitHub](https://github.com/Comfy-Org/embedded-docs/blob/main/comfyui_embedded_docs/docs/StartLoop/en.md)

***

**Source fingerprint (SHA-256):** `be34fedd4db9d4f4cc795855c87f6489f294e029da316b5dc66e5af7dff004a9`
