For Each

Iterate over an array of strings and execute downstream nodes once for each item

Node Type

Control Flow

Category

Loop

Icon

Repeat

Overview

The For Each node is a control flow node that takes an array of strings and causes the workflow to iterate over each item, executing downstream nodes separately for every value. This powerful looping mechanism allows you to process multiple items in sequence, making your workflows more dynamic and efficient.

Key Features

  • Array Iteration: Processes each item in an array sequentially
  • Downstream Execution: Executes connected nodes for each array item
  • Item Access: Provides current item and index to downstream nodes
  • Flexible Input: Accepts comma-separated lists or JSON arrays
  • Loop Control: Manages workflow execution flow for repetitive tasks
  • Data Processing: Enables batch processing of multiple data items

Prerequisites

Array Data Source

Must have an array of strings to iterate over

Array data available from upstream nodes
Data formatted as strings or JSON array
Non-empty array with valid content

Downstream Nodes

Workflow structure requirements

Connected Nodes: Must have downstream nodes connected to process each item
Data Handling: Downstream nodes should be configured to use loop outputs
Execution Flow: Workflow will execute downstream nodes for each array item

Technical Requirements

System capabilities needed

Loop Support: Workflow engine must support loop node execution
Array Parsing: Ability to parse JSON arrays and comma-separated values
Iteration Control: System tracks current item and iteration index

Node Configuration

Required Fields

list

Type:array
Required:Yes
Value Type:array_string

An array of strings to iterate over. Can be provided as a JSON array ['item1', 'item2'] or comma-separated values 'item1,item2,item3'. Each item will be processed sequentially by downstream nodes.

Examples & Use Cases

Bulk Email Processing

Send emails to multiple recipients

Workflow Structure

🔄 For Each (email list) → ✉️ Send Email → 📊 Log Result
{
  "list": [
    "user1@example.com",
    "user2@example.com",
    "user3@example.com"
  ]
}

Sends an email to each recipient in the list, one by one, and logs the result for each send operation.

Multi-URL Data Fetching

Fetch data from multiple URLs sequentially

Workflow Structure

🔄 For Each (URLs) → 🌐 Fetch Webpage → 🤖 AI Analysis → 💾 Store Results
{
  "list": [
    "https://example.com/page1",
    "https://example.com/page2",
    "https://example.com/page3"
  ]
}

Fetches content from multiple URLs, analyzes each with AI, and stores the results.

Batch File Processing

Process multiple files or documents

Use Case

Process a list of document IDs, file paths, or references, performing operations on each one individually.

{
  "list": [
    "doc-id-001",
    "doc-id-002",
    "doc-id-003"
  ]
}

Best Practices

Do's

  • Validate array is not empty before passing to For Each
  • Use the index output for progress tracking
  • Handle errors in downstream nodes for each iteration
  • Keep loop bodies focused on single, clear operations
  • Consider rate limiting for API calls in loops
  • Log iteration progress for debugging

Don'ts

  • Don't use extremely large arrays (>1000 items) without consideration
  • Avoid nested For Each loops when possible (use array flattening instead)
  • Don't ignore the original list output for reference
  • Avoid side effects that depend on iteration order if not necessary
  • Don't create infinite loops with recursive workflows
  • Avoid unnecessary processing - filter arrays before looping
💡
Pro Tip: When processing large arrays, consider adding delay nodes between iterations to avoid overwhelming external APIs or services. Use the index field to track progress and implement checkpointing for long-running loops.

Troubleshooting

Common Issues

Empty Array Error

Symptoms: Loop doesn't execute or skips entirely

Solution: Ensure the input array contains at least one item. Add validation before the For Each node to check array length.

Downstream Node Failures

Symptoms: Loop stops partway through

Solution: Add error handling in downstream nodes. Use If-Else nodes to check for success/failure and handle gracefully.

Performance Issues

Symptoms: Loop takes very long to complete

Solution: Reduce array size, optimize downstream nodes, or consider parallel processing alternatives if order doesn't matter.

Related Resources