# Concat Arrays

Concatenate multiple arrays using lodash _.concat

> Canonical page: https://elysiatools.com/en/tools/concat-arrays

- **Category:** Data Processing

- **Keywords:** array, concat, merge, join, combine, flatten, lodash

## Overview

## Features

- **Concatenate up to 5 arrays** into a single array
- **Automatic flattening** of nested arrays in the result
- **Optional deduplication** to remove duplicate values
- **Smart type detection** for numbers, booleans, and objects
- **Flexible input format** - JSON arrays or text representations

## Usage Examples

**Basic concatenation:**
```
Array 1: [1, 2]
Array 2: [3, 4]
Array 3: [5, 6]
Result: [1, 2, 3, 4, 5, 6]
```

**With nested arrays (auto-flattened):**
```
Array 1: [1, 2]
Array 2: [[3, 4], 5]
Result: [1, 2, 3, 4, 5]
```

**With deduplication enabled:**
```
Array 1: [1, 2, 3]
Array 2: [3, 4, 5]
Result (unique): [1, 2, 3, 4, 5]
```

**Mixed data types:**
```
Array 1: [1, "hello", true]
Array 2: [null, {key: "value"}, [6, 7]]
Result: [1, "hello", true, null, {key: "value"}, 6, 7]
```

## Inputs

- **Array 1** (textarea): \[1, 2\]
- **Array 2** (textarea): \[3, 4\]
- **Array 3** (textarea): \[5, 6\]
- **Array 4** (textarea): \[7, 8\]
- **Array 5** (textarea): \[9, 10\]
- **Flatten Mode** (select)
- **Remove Duplicates** (checkbox)

## When to use

- When you need to combine multiple arrays into a single list for batch processing or analysis.
- When dealing with nested arrays that require flattening to simplify data structures.
- When merging arrays while ensuring no duplicate values are included in the result.

## How it works

- Input up to five arrays in JSON or text format using the provided text areas.
- Select a flatten mode: 'none' to keep nested arrays, 'shallow' to flatten one level, or 'deep' to flatten all levels.
- Optionally enable the 'Remove Duplicates' checkbox to eliminate duplicate values based on strict equality.
- The tool concatenates the arrays and applies the selected options to produce the final array output.

## Use cases

- Merging data from multiple API responses or database queries into a single dataset for reporting.
- Combining lists from different sources, such as user IDs or product codes, while removing duplicate entries.
- Flattening nested array structures from JSON files to prepare data for analysis in tools like Excel or scripts.

## Frequently asked questions

### What is array concatenation?

Array concatenation is the process of joining two or more arrays end-to-end to form a new array.

### How does the flatten mode affect the result?

Flatten mode controls nested arrays: 'none' keeps them as is, 'shallow' flattens one level, and 'deep' flattens all nested levels.

### Can I remove duplicates from the concatenated array?

Yes, by enabling the 'Remove Duplicates' option, the tool will eliminate duplicate values using strict equality checks.

### What data types are supported?

The tool supports numbers, strings, booleans, null, objects, and arrays, with smart type detection for accurate concatenation.

### How many arrays can I concatenate at once?

You can concatenate up to five arrays simultaneously using the array1 to array5 input fields.

## Related tools

- [Remove By Predicate](https://elysiatools.com/en/tools/remove-by-predicate): Remove items that match a predicate using lodash _.remove
- [Uniq With](https://elysiatools.com/en/tools/uniq-with): Remove duplicates using lodash _.uniqWith and deep equality
- [Text Joiner](https://elysiatools.com/en/tools/text-joiner): Join multiple text inputs with custom separators
- [Difference Arrays](https://elysiatools.com/en/tools/difference-arrays): Remove values from array that are present in other arrays using lodash _.difference
- [CSV File Merger](https://elysiatools.com/en/tools/csv-merger): Merge multiple CSV files into a single file with options for header handling and deduplication
- [Array Flattener](https://elysiatools.com/en/tools/array-flattener): Flatten multidimensional arrays into one-dimensional arrays with customizable depth
- [Compact Array](https://elysiatools.com/en/tools/compact-array): Remove falsey values from array using lodash _.compact
- [Drop Items](https://elysiatools.com/en/tools/drop-items): Drop first N items from array using lodash _.drop

## Samples

- [Android Data Structures Java Samples](https://elysiatools.com/en/samples/android-datastructures-java): Android Java data structure examples including arrays, hash tables, and linked lists with common operations
- [Android Data Structures Kotlin Samples](https://elysiatools.com/en/samples/android-datastructures-kotlin): Android Kotlin data structure examples including arrays, hash tables, and linked lists with common operations
- [Duplicate Line Samples](https://elysiatools.com/en/samples/text-duplicate-line-samples): Sample files with various types of duplicate lines for testing duplicate removal tools
- [Special Characters Samples](https://elysiatools.com/en/samples/text-special-characters-samples): Sample text files with various special characters, punctuation, and symbols for testing non-alphanumeric character removal
