Skip to main content

List: Flatten

Flatten a nested list. Mirrors JavaScript's Array.prototype.flat.

Example
Depth: (unset, full)
Input: [[1, 2], [3, [4, 5]]]
Output: [1, 2, 3, 4, 5]

Depth: 1
Input: [[1, 2], [3, [4, 5]]]
Output: [1, 2, 3, [4, 5]]

Parameters

Depth

Maximum recursion depth. Leave empty to flatten all the way down. 1 flattens one level (the typical "spread one level of nesting" use). 0 is a no-op.

Input

ArrayREQUIRED

List to flatten (Array or JSON array).

Output

Result
The flattened list.