# Group By

Group items by a derived key using lodash _.groupBy

> Canonical page: https://elysiatools.com/en/tools/group-by

- **Category:** Data Processing

- **Keywords:** group, lodash, collection, object, array

## Overview

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"}]}`

## Inputs

- **Collection** (textarea): Enter a JSON array or object
- **Iteratee Type** (select)
- **Iteratee** (text): Property name or path when using property iteratee

## 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.

## Frequently asked questions

### 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.

## Related tools

- [Count By](https://elysiatools.com/en/tools/count-by): Count items by a derived key using lodash _.countBy
- [Find Key](https://elysiatools.com/en/tools/find-key): Find the first matching key using lodash _.findKey
- [Get Path](https://elysiatools.com/en/tools/get-path): Get a value at a path using lodash _.get
- [Index Of](https://elysiatools.com/en/tools/index-of): Find the index of a value in array using lodash _.indexOf
- [Initial Items](https://elysiatools.com/en/tools/initial-items): Get all elements except the last using lodash _.initial
- [Invert By](https://elysiatools.com/en/tools/invert-by): Invert keys grouped by values using lodash _.invertBy
- [Nth Item](https://elysiatools.com/en/tools/nth-item): Get the item at a specific index using lodash _.nth
- [Remove By Predicate](https://elysiatools.com/en/tools/remove-by-predicate): Remove items that match a predicate using lodash _.remove

## Samples

- [Grafana Advanced Application Samples](https://elysiatools.com/en/samples/grafana-samples): Comprehensive Grafana samples covering advanced dashboard design, alerting configurations, data source integrations, and plugin development
- [QR Code Samples](https://elysiatools.com/en/samples/qrcode-samples): Sample QR code images for testing QR code reading and generation tools
- [Postman Collections - API Testing](https://elysiatools.com/en/samples/postman-collections): Comprehensive Postman collection examples including API testing, automation scripts, environment variables, mock servers, and advanced testing patterns for REST APIs
- [D3.js Data Visualization Samples](https://elysiatools.com/en/samples/d3js-data-visualization): Comprehensive D3.js data visualization examples including charts, maps, animations, and interactive visualizations

## Related content

- [JSON Interchange and Format Translation Tools](https://elysiatools.com/en/hubs/json-convert): Compare JSON conversion tools for CSV, YAML, TOML, GraphQL, XML, Markdown, Excel, BSON, EDN, and related structured formats in one hub.
- [JSON Inspection, Diff, and Transformation Tools](https://elysiatools.com/en/hubs/json-utility): Compare JSON formatting, diffing, path inspection, schema validation, merging, transformation, and export tools in one hub for API and data workflows.
- [JSON Schema, Mock Data, and API Fixture Generators](https://elysiatools.com/en/hubs/json-generate): Curated tools for JSON schema generation, mock payload building, and API fixture preparation in one hub.
- [JSON Formatting, Diff, and Normalization Tools](https://elysiatools.com/en/hubs/json-format): Compare JSON formatting, diffing, log review, config comparison, and data-normalization tools in one hub for readable and reviewable JSON workflows.
