Categories

Uniq By

Remove duplicates from an array using lodash _.uniqBy with a property path

Remove duplicate values from an array using a property path.

Highlights:

  • Uses lodash _.uniqBy
  • Supports property paths (e.g. id, meta.key)
  • Returns unique values as JSON

Example:

  • Array: [{"id": 1}, {"id": 1}, {"id": 2}]
  • Path: id
  • Result: [{"id": 1}, {"id": 2}]

Enter a JSON array

Property path used to compare values

Key Facts

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

Overview

Uniq By is a powerful data processing utility that allows you to efficiently remove duplicate objects from a JSON array based on a specific property path using the reliable lodash _.uniqBy method.

When to Use

  • When you need to clean up API responses that contain redundant object entries.
  • When processing large datasets where you must ensure unique records based on a specific ID or key.
  • When you need to filter nested JSON structures by targeting specific property paths.

How It Works

  • Paste your JSON array into the input field.
  • Specify the property path (e.g., 'id' or 'user.email') you want to use for comparison.
  • The tool processes the array using lodash _.uniqBy to identify and remove duplicates.
  • Copy or download the resulting unique JSON array.

Use Cases

Cleaning up user lists by removing duplicate entries with the same email address.
Filtering product catalogs to ensure each item ID appears only once.
Standardizing configuration files by stripping out redundant settings objects.

Examples

1. Deduplicate User List

Data Analyst
Background
I have a list of users exported from a database, but some users appear multiple times due to system sync errors.
Problem
I need to remove duplicate user objects based on their unique 'email' field.
How to Use
Paste the user array into the input and enter 'email' in the Property Path field.
Example Config
path: 'email'
Outcome
A clean list where each email address appears exactly once.

2. Filter Nested API Response

Frontend Developer
Background
An API endpoint is returning a list of transactions, but some transactions are duplicated with the same 'transaction_id' inside a 'data' object.
Problem
I need to filter the array to keep only unique transactions based on the nested ID.
How to Use
Paste the JSON response and use 'data.transaction_id' as the property path.
Example Config
path: 'data.transaction_id'
Outcome
A refined array containing only unique transaction records.

Try with Samples

json, video

Related Hubs

FAQ

What does the Property Path field do?

It tells the tool which specific key or nested path to look at when determining if two objects are duplicates.

Can I use nested paths?

Yes, you can use dot notation (e.g., 'meta.id') to target properties nested within objects.

What happens if I leave the Property Path empty?

If no path is provided, the tool will treat the entire object as the value for comparison.

Is this tool case-sensitive?

Yes, the comparison follows standard JavaScript equality rules, meaning 'ID' and 'id' are treated as different values.

Does this tool modify my original data?

No, the tool processes your input and generates a new, unique output; your original data remains unchanged.

API Documentation

Request Endpoint

POST /en/api/tools/uniq-by

Request Parameters

Parameter Name Type Required Description
array textarea Yes Enter a JSON array
path text No Property path used to compare values

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-uniq-by": {
      "name": "uniq-by",
      "description": "Remove duplicates from an array using lodash _.uniqBy with a property path",
      "baseUrl": "https://elysiatools.com/mcp/sse?toolId=uniq-by",
      "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]