The Array Flatten node collects results from Array Splitter processing, combining individual items back into a single array output. This is essential for completing batch processing workflows.

How It Works

Array Flatten is the counterpart to Array Splitter:

Array Splitter:
  Input:  { items: [1, 2, 3] }
  Output: Three separate: 1, 2, 3

Processing: Each item processed individually

Array Flatten:
  Input:  Three separate: "result1", "result2", "result3"
  Output: { results: ["result1", "result2", "result3"] }

Configuration

Array Flatten automatically detects and collects outputs from upstream Array Splitter operations. No manual configuration is required.

Output Structure

{
  "out": [
    "first processed item",
    "second processed item",
    "third processed item"
  ],
  "count": 3,
  "originalInput": {...}
}

Common Usage Patterns

Complete Processing Pipeline

Dataset Source (items)
  → Array Splitter (split items)
  → Prompt (process each)
  → Array Flatten (collect results)
  → Dataset Sink (save all)

Multi-Step Processing

Website Mapper (discover URLs)
  → Array Splitter (split URLs)
  → Page Scraper (scrape each)
  → HTML Text Extractor (clean each)
  → Prompt (analyze each)
  → Array Flatten (collect analyses)
  → Prompt (summarize all)
  → Dataset Sink

Parallel Branch Collection

Array Splitter
  → Branch A: Prompt 1
  → Branch B: Prompt 2
  → Array Flatten (collects from both branches)
Tip
Always pair Array Splitter with Array Flatten to maintain structured data flow and enable downstream processing of collected results.

Order Preservation

Array Flatten maintains the order of items from the original Array Splitter:

  • Sequential processing: Order is always preserved
  • Parallel processing: Results are reordered to match input order
  • Failed items: Can be included or excluded based on configuration

Error Handling

Partial Failures

If some items fail during processing:

Input: 5 items split
Process: Items 1, 2, 4, 5 succeed; item 3 fails
Output: 
  - Success array: [result1, result2, result4, result5]
  - Failed items logged separately
  - Total count includes both success and failures
Warning
Check the error logs after Array Flatten to identify which items failed processing. The output array will only contain successful results.

All Items Fail

If all split items fail to process:

  • Array Flatten outputs an empty array
  • Downstream nodes receive empty input
  • Flow continues (doesn't stop)
  • Error details available in logs

Performance Considerations

Memory Usage

Array Flatten collects all results in memory:

  • Small arrays (<100 items): No issues
  • Medium arrays (100-1000 items): Monitor memory
  • Large arrays (1000+ items): Consider streaming or batching
  • Very large results: May need to write to dataset incrementally

Wait Time

Array Flatten waits for all split items to complete:

  • Sequential: Waits for each item in order
  • Parallel: Waits for slowest item
  • Timeout handling: Configure max wait time if needed

Best Practices

Always Use After Array Splitter

Don't leave Array Splitter outputs uncollected:

✅ Good:
Array Splitter → Process → Array Flatten → Continue

❌ Bad:
Array Splitter → Process → (no flatten) → Dataset Sink
(Only saves last item!)

Place Strategically

Position Array Flatten where you need the full collection:

Option 1: Flatten immediately
Array Splitter → Process → Array Flatten → More Processing

Option 2: Flatten after multiple steps
Array Splitter → Step 1 → Step 2 → Step 3 → Array Flatten

Handle Empty Results

Prepare downstream nodes for potentially empty arrays:

Array Flatten → Check if empty → Continue or skip

Advanced Patterns

Nested Flattening

When using multiple Array Splitters, use matching Array Flattens:

Array Splitter 1 (outer)
  → Array Splitter 2 (inner)
    → Process
    → Array Flatten 2 (collect inner)
  → Array Flatten 1 (collect outer)

Conditional Flattening

Filter or transform items before flattening:

Array Splitter
  → Process
  → Filter (keep only successful)
  → Array Flatten (collect filtered)

Aggregation After Flattening

Use the flattened array for aggregate operations:

Array Flatten (collect all results)
  → Prompt: "Summarize these {count} results: {results}"
  → Generate aggregate report

Debugging Tips

Check Array Sizes

Monitor the count field to verify all items were collected:

Expected: 10 items split
Flattened count: 8 items
→ 2 items failed or were filtered

Inspect Individual Results

Review the flattened array to identify issues:

  • Look for null or undefined values
  • Check for error messages in results
  • Verify data structure consistency
  • Compare with expected outputs

Test with Small Arrays

Always test your split-process-flatten logic with 2-3 items first:

  • Easier to debug
  • Faster iteration
  • Clear visibility into each step
  • Validates logic before scaling
Tip
Use Array Flatten's output in a Prompt node to generate summaries like "Processed {count} items: {results}" for clear flow monitoring.

Integration Examples

With Dataset Sink

Array Flatten
  → Map: out (array) → Dataset Sink
  → Each array item becomes a dataset row

With Prompt for Summary

Array Flatten
  → Prompt: "Analyze these {count} results and provide insights"
  → Generate executive summary

With Further Processing

Array Flatten (collect processed items)
  → Transform or filter array
  → Split again for second-stage processing
  → Flatten again for final output

Related Documentation

Array Splitter
Split arrays for individual processing
Variable Mapping
Map flattened results to other nodes
Batch Processing
Optimize large-scale workflows