Flatten
flatten · Nodes · Utility
Flattens nested arrays into a single array.
Flatten#
Combine multiple inputs into a single flat list by spreading array items and wrapping non-arrays as single-item arrays.
When to Use#
Use the Flatten node when you need to:
- Combine multiple lists into a single concatenated list
- Merge workflow branches that each produce lists of items
- Normalize mixed data (some arrays, some single values) into a uniform list
- Prepare data for batch processing nodes that expect a flat array input
Contrast with Merge node:
- Merge (List mode):
[[a, b], [c, d]]— preserves each input as a nested array item - Flatten:
[a, b, c, d]— spreads array items into a single flat array
How It Works#
The Flatten node processes each input in order:
- For each input socket (
input_1,input_2, etc.) - If the input value is an array: all items are spread into the output
- If the input value is not an array: the value is wrapped as a single-item array
- All items are concatenated in input order
Configuration#
Input Count — Number of input sockets to create.
- Default:
2 - Minimum:
1 - Inputs are named
input_1,input_2, etc.
Inputs#
input_1, input_2, ... — Values to flatten.
- Type:
any(arrays are spread, other values are wrapped) - All inputs are required
- Number of inputs determined by
input_countconfiguration
Outputs#
output — Flattened array containing all items.
- Type:
array - Structure:
[item1, item2, item3, ...] - Items appear in the order inputs are connected
Examples#
Example 1: Combining Two Lists#
You have two branches that each return a list of document IDs:
Branch A: ["doc-1", "doc-2"]
Branch B: ["doc-3", "doc-4"]
Configuration:
- Input Count:
2
Result:
["doc-1", "doc-2", "doc-3", "doc-4"]
Example 2: List + Single Item#
One branch returns a list, another returns a single document:
Branch A: ["doc-1", "doc-2"]
Branch B: "doc-3"
Result:
["doc-1", "doc-2", "doc-3"]
The single item "doc-3" is automatically wrapped as ["doc-3"] and concatenated.
Example 3: Multiple Single Items#
All branches return single values:
Branch A: "doc-1"
Branch B: "doc-2"
Branch C: "doc-3"
Configuration:
- Input Count:
3
Result:
["doc-1", "doc-2", "doc-3"]
Each single value is wrapped and combined into a single list.
Example 4: Workflow Use Case#
Combining search results from multiple sources:
[Search Node: reddit posts] ─┐
[Search Node: hackernews] ───┼──> [Flatten] ──> [Display List]
[Constant: "featured"] ──────┘
The Flatten node combines the Reddit list, HN list, and single featured item into one displayable list.
Runtime Errors#
| Error | Cause | Remediation |
|---|---|---|
| No errors expected | — | This node has simple type coercion behavior |
Common Mistakes#
- Expecting nested structure preservation: Flatten spreads arrays. If you need
[[a, b], [c]], use the Merge node in List mode instead. - Wrong input count: If you configure 2 inputs but connect 3 branches, only the first 2 are processed. Increase
input_countto match your workflow.
Tips#
- Use with AI agent nodes that return lists of findings to combine multiple agent outputs
- Place before table insert nodes when batch-inserting rows from multiple sources
- Combine with the Constant node to inject static items into a dynamic list
- Works well with the HTTP Request node's paginated response arrays
Inputs
input_1Requiredinput_2Required
Outputs
output
Configuration
| Field | Type | Required | Description |
|---|---|---|---|
input_count | integer | No | Number of input sockets (named input_1, input_2, etc.) |
base_config | record | No | Shared node configuration. failure_mode decides what a failure of this node does to the workflow; leave it at the default stop unless the workflow handles the failure itself on the node's error output (route_to_error) or the node is a rare emergency kill switch (stop_workflow). |