Categories

Concat Arrays

Concatenate multiple arrays using lodash _.concat

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]

Key Facts

Category
Data Processing
Input Types
textarea, select, checkbox
Output Type
text
Sample Coverage
4
API Ready
Yes

Overview

Concat Arrays is a utility tool that merges up to five arrays into a single array using lodash's _.concat method. It supports optional flattening of nested arrays and deduplication to remove duplicate values, making it ideal for combining data from multiple sources.

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.

Examples

1. Combine User ID Lists

Background
A developer has three separate arrays of user IDs from authentication, profile, and activity modules.
Problem
Need to merge these arrays into one for a batch update operation without duplicates.
How to Use
Enter each array in the array1, array2, and array3 fields, then enable 'Remove Duplicates' and concatenate.
Outcome
A single array containing all unique user IDs from the three modules, ready for processing.

2. Flatten Nested Sales Data

Background
A data analyst receives sales figures as nested arrays from regional reports, with some duplicate entries.
Problem
The nested structure complicates analysis, and duplicates need to be removed for accurate totals.
How to Use
Input the arrays, set flatten mode to 'deep', and enable 'Remove Duplicates' before concatenating.
Outcome
A flattened array with unique sales figures, simplifying further analysis and visualization.

Try with Samples

video

Related Hubs

FAQ

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.

API Documentation

Request Endpoint

POST /en/api/tools/concat-arrays

Request Parameters

Parameter Name Type Required Description
array1 textarea Yes -
array2 textarea No -
array3 textarea No -
array4 textarea No -
array5 textarea No -
flattenMode select No -
unique checkbox No -

Response Format

{
  "result": "Processed text content",
  "error": "Error message (optional)",
  "message": "Notification message (optional)",
  "metadata": {
    "key": "value"
  }
}
Text: Text

AI MCP Documentation

Add this tool to your MCP server configuration:

{
  "mcpServers": {
    "elysiatools-concat-arrays": {
      "name": "concat-arrays",
      "description": "Concatenate multiple arrays using lodash _.concat",
      "baseUrl": "https://elysiatools.com/mcp/sse?toolId=concat-arrays",
      "command": "",
      "args": [],
      "env": {},
      "isActive": true,
      "type": "sse"
    }
  }
}

You can chain multiple tools, e.g.: `https://elysiatools.com/mcp/sse?toolId=png-to-webp,jpg-to-webp,gif-to-webp`, max 20 tools.

If you encounter any issues, please contact us at [email protected]