> ## Documentation Index
> Fetch the complete documentation index at: https://docs.odella.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Flatten Block

> Flatten nested arrays into a single-level array

<Frame>
  <img src="https://mintcdn.com/odella/I7v1Fbrp2kx7rLoj/block-reference/assets/flatten_light.png?fit=max&auto=format&n=I7v1Fbrp2kx7rLoj&q=85&s=c22c67b861a9256e65d158b3b7809dc2" alt="Flatten Block Screenshot" className="block dark:hidden" width="720" height="312" data-path="block-reference/assets/flatten_light.png" />

  <img src="https://mintcdn.com/odella/I7v1Fbrp2kx7rLoj/block-reference/assets/flatten_dark.png?fit=max&auto=format&n=I7v1Fbrp2kx7rLoj&q=85&s=8860ab9b0f3cf8b0fe7a762a2ef6944c" alt="Flatten Block Screenshot" className="hidden dark:block" width="700" height="350" data-path="block-reference/assets/flatten_dark.png" />
</Frame>

## Overview

The Flatten Block is designed to simplify complex nested array structures by flattening them into a single-level array. This block is particularly useful when dealing with multi-dimensional arrays or when you need to process all elements of a nested structure in a linear fashion.

## Key Features

* Flattens nested arrays one level deep
* Preserves the order of elements from the original nested structure
* Handles arrays containing both nested arrays and non-array elements

## Inputs

<ParamField path="input" type="any[][]" required>
  The nested array structure to be flattened. Must be a nested array (array of arrays). Non-nested arrays or other types will result in an error.
</ParamField>

## Outputs

<ResponseField name="output" type="any[]">
  The resulting flattened array containing all elements from the input, with one level of nesting removed.
</ResponseField>

## Example: Flattening a Nested Array

1. Create an Array Block with a nested array structure, e.g., `[[1, 2], [3, 4], [5, 6]]`.
2. Add a Flatten Block and connect the Array Block to its `input`.
3. Run the flow. The Flatten Block's `output` will be `[1, 2, 3, 4, 5, 6]`.

## Error Handling

* If no input is provided, the block will error with "Input is required"
* If the input is not a nested array (array of arrays), the block will error with "Input is not a nested array"
* The block will only flatten one level deep - for deeper nesting, multiple Flatten blocks can be chained

## FAQ

<AccordionGroup>
  <Accordion title="Does the Flatten Block work with objects?">
    No, the Flatten Block is designed to work only with nested arrays. It will error if given objects or other non-array inputs.
  </Accordion>

  <Accordion title="How deep does the flattening go?">
    The Flatten Block only flattens one level deep. For example, `[[1, [2, 3]], [4, 5]]` becomes `[1, [2, 3], 4, 5]`. To flatten deeper levels, chain multiple Flatten blocks together.
  </Accordion>
</AccordionGroup>

## See Also

* [Array Block](/block-reference/data/array)
* [Map Block](/block-reference/modifiers/flatten)
* [Filter Block](/block-reference/modifiers/filter)
