# Array Operations

Perform set operations (intersection, union, difference) on two arrays

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

- **Category:** Data Processing

- **Keywords:** array, set, intersection, union, difference, combine, compare, merge

## Overview

The Array Operations tool allows you to quickly perform mathematical set operations on two lists of data. Whether you need to find common elements, merge lists, or identify unique differences, this utility simplifies complex array comparisons into a single click.

## Inputs

- **First Array** (textarea): Enter array as JSON format: \[3, 1, 2\] or comma-separated values: 3, 1, 2 or one per line
- **Second Array** (textarea): Enter array as JSON format: \[3, 1, 2\] or comma-separated values: 3, 1, 2 or one per line
- **Operation** (select)
- **Case Sensitive (for strings)** (checkbox)
- **Trim Whitespace (for strings)** (checkbox)
- **Custom Separator (for text input)** (text): Enter separator (default: comma, semicolon, or newline)

## When to use

- When you need to identify common items between two large datasets or lists.
- When you want to merge two lists while removing duplicate entries.
- When you need to compare two configurations or user lists to find missing or extra items.

## How it works

- Input your first and second arrays using JSON format, comma-separated values, or one item per line.
- Select the desired set operation, such as Intersection, Union, or Difference, from the dropdown menu.
- Adjust optional settings like case sensitivity or whitespace trimming to ensure data consistency.
- Click the process button to generate the resulting array based on your selected logic.

## Use cases

- Comparing two customer email lists to find new leads that are not yet in your CRM.
- Merging two product inventory lists while automatically deduplicating shared items.
- Validating if a specific set of user permissions is a subset of a broader security group.

## Frequently asked questions

### What input formats are supported?

You can provide arrays as JSON lists (e.g., [1, 2, 3]), comma-separated values, or by placing each item on a new line.

### How does the 'Difference' operation work?

The Difference (A - B) operation returns all elements that are present in the first array but not in the second array.

### Can I compare strings with different casing?

Yes, you can toggle the 'Case Sensitive' option off to treat 'Apple' and 'apple' as the same value.

### What is the difference between Union and Intersection?

Union (A ∪ B) combines all unique elements from both arrays, while Intersection (A ∩ B) returns only the elements found in both arrays.

### Are there limits to the number of items I can process?

The tool is designed for efficient browser-based processing, capable of handling thousands of items instantly.

## Related tools

- [Intersection Arrays](https://elysiatools.com/en/tools/intersection-arrays): Find common values across multiple arrays using lodash _.intersection
- [JSON File Merger](https://elysiatools.com/en/tools/json-merger): Merge multiple JSON files with various merging strategies (deep merge, overwrite, combine arrays, etc.)
- [YAML File Merger](https://elysiatools.com/en/tools/yaml-merger): Merge multiple YAML files with various strategies (deep merge, overwrite, combine arrays, etc.)
- [Concat Arrays](https://elysiatools.com/en/tools/concat-arrays): Concatenate multiple arrays using lodash _.concat
- [Text Diff](https://elysiatools.com/en/tools/text-diff): Compare two text inputs and show differences
- [Markdown Merger](https://elysiatools.com/en/tools/markdown-merger): Merge multiple markdown files with smart header level adjustment and table of contents generation
- [TXT File Merger](https://elysiatools.com/en/tools/txt-merger): Merge multiple text files with various strategies (concatenate, interleave, etc.)
- [Difference Arrays](https://elysiatools.com/en/tools/difference-arrays): Remove values from array that are present in other arrays using lodash _.difference

## Samples

- [Android File Operations Java Samples](https://elysiatools.com/en/samples/android-file-operations-java): Android Java file operations examples including text file read/write, file copy/move, directory traversal, and file validation
- [Android File Operations Kotlin Samples](https://elysiatools.com/en/samples/android-file-operations-kotlin): Android Kotlin file operations examples including text file read/write, file copy/move, directory traversal, and file validation
- [macOS File Operations Objective-C Samples](https://elysiatools.com/en/samples/macos-file-operations-objectivec): macOS Objective-C file operations examples including text file read/write, file copy/move, directory traversal, and file validation
- [macOS File Operations Swift Samples](https://elysiatools.com/en/samples/macos-file-operations-swift): macOS Swift file operations examples including text file read/write, file copy/move, directory traversal, and file validation

## Related content

- [Array and List Data Organization Tools](https://elysiatools.com/en/hubs/array-and-list-manipulation-tools): Inspect, clean, filter, deduplicate, reshape, slice, and order arrays or lists for downstream data use.
