# Flatten Deep Array

Flatten array completely using lodash _.flattenDeep

> Canonical page: https://elysiatools.com/en/tools/flatten-deep-array

- **Category:** Data Processing

- **Keywords:** array, flatten, deep, recursive, lodash, nested

## Overview

Recursively flatten an array to completely eliminate all nesting.

## Features:
- Accepts deeply nested JSON arrays of any depth
- Recursively flattens all levels of nesting
- Produces a single-level array
- Handles arrays with mixed data types
- Uses lodash _.flattenDeep for complete flattening

## Examples:
- Input: [1, [2, [3, [4]]], 5] → Output: [1, 2, 3, 4, 5]
- Input: [[["a", "b"], ["c", "d"]], ["e", "f"]] → Output: ["a", "b", "c", "d", "e", "f"]
- Input: [1, [2, [3, [4, [5]]]]] → Output: [1, 2, 3, 4, 5]

## Use Cases:
- **Deep Data Extraction**: Extract all elements from deeply nested structures
- **Data Normalization**: Convert complex nested arrays to simple lists
- **Search Operations**: Flatten data for easier searching and filtering
- **Array Manipulation**: Prepare data for algorithms that require flat arrays

## Inputs

- **Array Input** (textarea): Enter a valid JSON array with deeply nested elements

## When to use

- When you need to extract all elements from a deeply nested array structure.
- When preparing data for algorithms or operations that require flat, single-level arrays.
- When normalizing complex nested data into a simple list for analysis or manipulation.

## How it works

- Input a valid JSON array with nested elements into the provided textarea.
- The tool recursively traverses all levels of nesting in the array.
- It flattens the array completely into a single dimension using lodash _.flattenDeep.
- Outputs the flattened array as plain text for further use.

## Use cases

- Deep Data Extraction: Pull all elements from nested API responses or data structures.
- Data Normalization: Convert complex nested arrays into simple lists for reporting or analysis.
- Search Operations: Flatten data to enable easier searching, filtering, or iteration.

## Frequently asked questions

### What does this tool do?

It recursively flattens a deeply nested JSON array into a single-level array.

### How do I use it?

Paste your nested array into the input field and the tool will output the flattened version.

### What types of arrays can it handle?

It accepts any valid JSON array with mixed data types and arbitrary nesting depth.

### Is there a limit to the nesting depth?

No, it uses lodash _.flattenDeep to handle arrays of any depth recursively.

### Can it process arrays with non-array elements?

Yes, it preserves all elements, including numbers, strings, or objects, in the flattened output.

## Related tools

- [Defaults Deep](https://elysiatools.com/en/tools/defaults-deep): Apply deep default values using lodash _.defaultsDeep
- [Uniq With](https://elysiatools.com/en/tools/uniq-with): Remove duplicates using lodash _.uniqWith and deep equality
- [Get Path](https://elysiatools.com/en/tools/get-path): Get a value at a path using lodash _.get
- [Group By](https://elysiatools.com/en/tools/group-by): Group items by a derived key using lodash _.groupBy
- [Head Item](https://elysiatools.com/en/tools/head-item): Get the first element of array using lodash _.head
- [Index Of](https://elysiatools.com/en/tools/index-of): Find the index of a value in array using lodash _.indexOf
- [Initial Items](https://elysiatools.com/en/tools/initial-items): Get all elements except the last using lodash _.initial
- [Intersection Arrays](https://elysiatools.com/en/tools/intersection-arrays): Find common values across multiple arrays using lodash _.intersection

## Samples

- [Grafana Advanced Application Samples](https://elysiatools.com/en/samples/grafana-samples): Comprehensive Grafana samples covering advanced dashboard design, alerting configurations, data source integrations, and plugin development
- [QR Code Samples](https://elysiatools.com/en/samples/qrcode-samples): Sample QR code images for testing QR code reading and generation tools
- [D3.js Data Visualization Samples](https://elysiatools.com/en/samples/d3js-data-visualization): Comprehensive D3.js data visualization examples including charts, maps, animations, and interactive visualizations
- [Rome JavaScript Toolchain Samples](https://elysiatools.com/en/samples/rome): Rome JavaScript toolchain examples including configuration, linting, formatting, bundling, and project management
