# Difference Arrays

Remove values from array that are present in other arrays using lodash _.difference

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

- **Category:** Data Processing

- **Keywords:** array, difference, exclude, filter, remove, lodash

## Overview

This tool uses lodash's `_.difference` method to create an array of unique values that are not present in the other provided arrays.

**Features:**
- Strict equality comparison (===)
- Supports multiple exclude arrays
- Case-sensitive/insensitive string comparison
- Validates JSON array input format

**Example:**
- Input array: `[2, 1, 2, 3]`
- Exclude: `[2, 3]`
- Result: `[1]`

## Inputs

- **Source Array** (textarea): \[2, 1, 2, 3\]
- **Exclude Array 1** (textarea): Values to exclude from source array
- **Exclude Array 2** (textarea): Additional values to exclude (optional)
- **Exclude Array 3** (textarea): More values to exclude (optional)
- **Case Sensitive** (checkbox): For string comparison, uncheck for case-insensitive matching

## When to use

- When you need to find elements in an array that are not in another array.
- For data cleaning tasks where specific values must be excluded from a dataset.
- To compare lists and identify differences, such as in inventory or user management.

## How it works

- Input the source array as a JSON array in the designated field.
- Provide one or more exclude arrays to specify values to remove.
- Optionally, adjust the case sensitivity setting for string comparisons.
- The tool processes the arrays using lodash's difference function and outputs the filtered result.

## Use cases

- Filtering user IDs to exclude banned or inactive users from a list.
- Comparing product catalogs to find items not available in current inventory.
- Cleaning data by removing known invalid or duplicate entries from datasets.

## Frequently asked questions

### What does this tool do?

It removes values from a source array that are present in one or more exclude arrays using lodash's _.difference method.

### How should I format the input arrays?

All arrays must be in valid JSON format, such as [1, 2, 3] or ['a', 'b', 'c'].

### Can I exclude values from multiple arrays simultaneously?

Yes, you can use up to three exclude arrays to filter out values from the source array.

### How does case sensitivity affect string comparisons?

When enabled, string comparisons are case-sensitive; disable it for case-insensitive matching.

### What happens to duplicate values in the source array?

The output array contains unique values, as lodash's difference function handles duplicates by returning only distinct values not in the excludes.

## Related tools

- [Array Deduplicator](https://elysiatools.com/en/tools/array-deduplicator): Remove duplicate elements from arrays with various deduplication methods
- [Array Filter](https://elysiatools.com/en/tools/array-filter): Filter out elements of specific types from arrays (remove numbers, strings, booleans, etc.)
- [Compact Array](https://elysiatools.com/en/tools/compact-array): Remove falsey values from array using lodash _.compact
- [Pull Values](https://elysiatools.com/en/tools/pull-values): Remove specific values from an array using lodash _.pull
- [BOM Character Remover](https://elysiatools.com/en/tools/data-bom-remover): Remove BOM (Byte Order Mark) characters from text and file content. Perfect for cleaning up text files that have encoding issues, fixing CSV imports, and preparing data for processing. Features: - Detect and remove UTF-8 BOM (EF BB BF) - Detect and remove UTF-16 BOM (FE FF or FF FE) - Detect and remove UTF-32 BOM (00 00 FE FF or FF FE 00 00) - Support multiple input formats - Visual BOM character display - Detailed detection report - Support for batch text processing Common Use Cases: - Fix CSV file import errors - Clean up text file encoding issues - Prepare data for JSON parsing - Fix XML parsing problems - Resolve API data encoding conflicts - Standardize text data format
- [Array Element Deleter](https://elysiatools.com/en/tools/array-element-deleter): Delete specific elements from arrays with support for multiple deletion methods
- [Data Boundary Processor](https://elysiatools.com/en/tools/data-boundary-processor): Advanced boundary value processing tool that identifies and handles minimum/maximum values in numerical data. Perfect for data validation, range checking, statistical analysis, and data preprocessing. Features: - Multiple boundary detection methods (absolute, percentile, standard deviation) - Flexible handling strategies (clip, remove, replace, transform) - Custom range validation - Asymmetric boundary handling - Batch processing capabilities - Comprehensive boundary statistics - Data quality assessment - Visual boundary reports Common Use Cases: - Data validation and quality control - Sensor data range checking - Financial data limit enforcement - Statistical data preprocessing - Machine learning feature engineering - Database constraint validation
- [Drop Items](https://elysiatools.com/en/tools/drop-items): Drop first N items from array using lodash _.drop

## Samples

- [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
- [Code Comment Samples](https://elysiatools.com/en/samples/code-comment-samples): Sample code files with various comment styles for testing comment removal
- [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

## Related content

- [File and Data Diff Comparison Tools](https://elysiatools.com/en/hubs/file-data-diff-comparison-tools): Compare two candidate artifacts, choose the right diff path for the format, review structural or semantic changes, and finish with integrity checks when approval needs byte-level certainty.
