Skip to content

Flatten

The Flatten node unwraps nested arrays into a single flat list. Use it when rows contain array fields that you want to iterate over individually.

Configuration

PropertyTypeDefaultDescription
fieldstring--The field containing nested arrays to flatten. If empty, flattens one level of the top-level array.

Input

Accepts an array of rows (or an array of arrays).

Output

Returns a flat array with nested items extracted to the top level.

How It Works

With field specified

For each input row, the node reads the value of field. If it is an array, each item in that array becomes a separate row in the output:

Input:

json
[
  { "name": "Order 1", "items": [{"product": "A"}, {"product": "B"}] },
  { "name": "Order 2", "items": [{"product": "C"}] }
]

Config: field: "items"

Output:

json
[
  { "product": "A" },
  { "product": "B" },
  { "product": "C" }
]

If a nested item is a scalar (not an array), it is wrapped: { "items": "scalar_value" }.

Without field (top-level flattening)

The node flattens one level of nesting from the top-level array:

Input:

json
[
  [{ "id": 1 }, { "id": 2 }],
  [{ "id": 3 }],
  { "id": 4 }
]

Output:

json
[
  { "id": 1 },
  { "id": 2 },
  { "id": 3 },
  { "id": 4 }
]

Non-array items pass through unchanged.

Example Use Cases

Flatten order items for a report

field: "line_items"

Convert a list of orders (each with a line_items array) into a flat list of all line items.

Flatten grouped data

After a Group By node, flatten all _group_items back into a single list:

field: "_group_items"

Flatten nested API responses

External APIs sometimes return nested structures. Use Flatten to normalize them into a flat row list.

TIP

Flatten is the inverse of Group By. Group By collects rows into groups; Flatten extracts items from groups back into a flat list.