Categories

Group By

Group items by a derived key using lodash _.groupBy

Group items by a derived key from a collection.

Highlights:

  • Uses lodash _.groupBy
  • Accepts JSON arrays or objects
  • Supports identity or property/path iteratees

Example:

  • Collection: [{"type":"a"},{"type":"b"},{"type":"a"}]
  • Iteratee: type
  • Result: {"a":[{"type":"a"},{"type":"a"}],"b":[{"type":"b"}]}

Enter a JSON array or object

Property name or path when using property iteratee

Key Facts

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

Overview

The Group By tool allows you to organize complex JSON collections into structured groups based on a specific property or path, powered by the reliable lodash _.groupBy function.

When to Use

  • When you need to categorize items in a large JSON array by a shared attribute.
  • When you want to transform a flat list of objects into a dictionary for faster lookups.
  • When preparing data for reports or UI components that require grouped data structures.

How It Works

  • Paste your JSON array or object into the Collection field.
  • Select the Iteratee Type to determine how the grouping key is derived.
  • Specify the property name or path if using the Property/Path mode.
  • Run the tool to receive a new JSON object where keys represent the groups and values contain the associated items.

Use Cases

Organizing user logs by status codes (e.g., 200, 404, 500).
Grouping product inventory lists by category or manufacturer.
Sorting transaction records by date or customer ID.

Examples

1. Categorizing Product Inventory

Background
An e-commerce manager has a flat list of products and needs to display them by category on a dashboard.
Problem
The raw data is a single array, making it difficult to render category-specific sections.
How to Use
Input the product array, set Iteratee Type to 'Property/Path', and set Iteratee to 'category'.
Example Config
Collection: [{"name":"Laptop","category":"Electronics"},{"name":"Shirt","category":"Apparel"},{"name":"Phone","category":"Electronics"}]
Outcome
A JSON object grouped by category, with 'Electronics' containing the laptop and phone, and 'Apparel' containing the shirt.

2. Grouping API Response Logs

Background
A developer is debugging server logs and needs to see all failed requests together.
Problem
The logs are mixed together, making it hard to identify patterns in error codes.
How to Use
Input the log array, set Iteratee Type to 'Property/Path', and set Iteratee to 'status'.
Example Config
Collection: [{"id":1,"status":200},{"id":2,"status":500},{"id":3,"status":200}]
Outcome
A grouped object where keys '200' and '500' contain their respective log entries, allowing for quick analysis of errors.

Try with Samples

json

Related Hubs

FAQ

What input formats are supported?

The tool accepts standard JSON arrays or objects.

What is the difference between Identity and Property/Path?

Identity groups items by their own values, while Property/Path allows you to specify a key or nested path within each object to group by.

Does this tool modify my original data?

No, it processes your input and returns a new structured result without altering the original source.

Can I group by nested properties?

Yes, by selecting Property/Path and providing the dot-notation path to the nested key.

Is this tool based on a specific library?

Yes, it utilizes the industry-standard lodash _.groupBy function for consistent and accurate results.

API Documentation

Request Endpoint

POST /en/api/tools/group-by

Request Parameters

Parameter Name Type Required Description
collection textarea Yes Enter a JSON array or object
iterateeType select No -
iteratee text No Property name or path when using property iteratee

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-group-by": {
      "name": "group-by",
      "description": "Group items by a derived key using lodash _.groupBy",
      "baseUrl": "https://elysiatools.com/mcp/sse?toolId=group-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]