Categories

Difference Arrays

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

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]

Values to exclude from source array

Additional values to exclude (optional)

More values to exclude (optional)

For string comparison, uncheck for case-insensitive matching

Key Facts

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

Overview

This tool uses lodash's _.difference method to filter out values from a source array that are present in one or more exclude arrays, returning a unique array of values not found in the excludes.

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.

Examples

1. User ID Filtering

Database Administrator
Background
You maintain a list of active user IDs and need to remove those on a temporary ban list.
Problem
Manually checking and removing banned IDs is inefficient and error-prone.
How to Use
Enter the source array of user IDs and the exclude array of banned IDs in the tool.
Example Config
Source: [101, 102, 103, 104], Exclude: [102, 104]
Outcome
The tool returns [101, 103], which are the active user IDs not banned.

2. Inventory Check

Background
An online store has a master list of products and wants to identify out-of-stock items based on current inventory.
Problem
Cross-referencing large product lists manually is time-consuming.
How to Use
Input the master product array and the inventory array as the exclude array.
Outcome
A list of products not in inventory, indicating items that need restocking.

Try with Samples

video, text

Related Hubs

FAQ

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.

API Documentation

Request Endpoint

POST /en/api/tools/difference-arrays

Request Parameters

Parameter Name Type Required Description
array textarea Yes -
exclude1 textarea Yes Values to exclude from source array
exclude2 textarea No Additional values to exclude (optional)
exclude3 textarea No More values to exclude (optional)
caseSensitive checkbox No For string comparison, uncheck for case-insensitive matching

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-difference-arrays": {
      "name": "difference-arrays",
      "description": "Remove values from array that are present in other arrays using lodash _.difference",
      "baseUrl": "https://elysiatools.com/mcp/sse?toolId=difference-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]