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
Downstream Nodes
Workflow structure requirements
Technical Requirements
System capabilities needed
Node Configuration
Required Fields
list
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
{
"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
{
"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
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.