---
title: "flatten · RUAL Documentation"
description: "Accepts a nested array and returns a flattened array."
canonical: https://docs.rual.nl/block-types/array/array_nested_join
language: en
---

# flatten

This block is part of the [`array`](https://docs.rual.nl/block-types/array) group and was last modified in core [`v10.6.1`](https://docs.rual.nl/core-versions/100601).

Accepts a nested array and returns a flattened array.

- array required `array` Input pin for the nested array to be flattened.

- max depth required `number` Optional input pin to specify the maximum depth for flattening (optional). • Hidden when unused

- Array `array` Output pin for the flattened array.

Recursively flattens nested arrays into one flat array. A maxdepth greater than 0 flattens only that many levels, keeping deeper arrays intact as elements; 0 or unset flattens completely. Non-array input outputs null. Example: [[1,[2]],3] -> [1,2,3] fully, or [1,[2],3] with maxdepth 1.

| `nested` |
| --- |

A typical wiring for [flatten](https://docs.rual.nl/block-types/array/array_nested_join): [select field values](https://docs.rual.nl/block-types/array/array_get_values_from_bp_field) feeds the `array` pin; [number](https://docs.rual.nl/block-types/number/number_default) feeds the `maxdepth` pin; the `array` out pin feeds [remove duplicates](https://docs.rual.nl/block-types/array/array_remove_duplicates).

![Studio canvas example for the flatten block: typical wiring for flatten.](https://docs.rual.nl/canvas-examples/array_nested_join.png)

### Commonly used with

In production blueprints, this block is most often wired together with:

- [select field values](https://docs.rual.nl/block-types/array/array_get_values_from_bp_field): feeds into this block. returns an array with values of the given field in this array of objects.

- [remove duplicates](https://docs.rual.nl/block-types/array/array_remove_duplicates): this block feeds into it. Removes duplicate values from an array.

- [array includes](https://docs.rual.nl/block-types/condition/condition_array_contains_string): this block feeds into it. determines whether an array includes a certain value among its entries.

- [exclude by value](https://docs.rual.nl/block-types/array/array_filter_value): this block feeds into it. Removes the items equal to the given value. Returns all items that do NOT match.

- [find by key - value](https://docs.rual.nl/block-types/array/array_get_objects_by_field_value): this block feeds into it. Returns the matching objects for the given key value pair.

- [map](https://docs.rual.nl/block-types/array/array_map): this block feeds into it. Creates a new array with the results of the provided function on every element in the array.

### Version history

Introduced in [`v10.6.1`](https://docs.rual.nl/core-versions/100601).
