JSON Group By

Group JSON Arrays
by Field

Organize a JSON array of objects by any field value — group by category, status, date, or any key. Get a grouped JSON object in one click.

Open JSON Group By Tool

Grouped JSON in four steps

Paste your JSON array Drop any JSON array of objects into the input — as compact or pretty-printed as you like.
Click Group By Find the Group By button in the Format tab toolbar to start the grouping operation.
Enter the field name Type the key you want to group by — e.g. "status", "category", or "department".
Get grouped JSON object The array is reorganized into an object keyed by unique field values. Copy or download instantly.

No account. No upload. No nonsense.

🔒

No Server

Your JSON never leaves your device. All grouping runs locally in your browser.

Instant Results

Grouping completes in milliseconds even for large JSON arrays with thousands of records.

📡

Works Offline

Load once and use forever — even on a plane or without internet access.

Related JSON tools

JSON Formatter Pretty-print JSON with syntax highlighting and a collapsible tree view.
JSON Filter Filter JSON arrays using JSONPath expressions and condition-based queries.
JSON Path Evaluator Evaluate full JSONPath expressions with wildcards, slices, and recursive descent.
JSON to CSV Export JSON arrays to CSV for spreadsheet analysis and reporting.

Common questions answered

How do I group a JSON array by a field?

Paste your JSON array in the Format tab, click the 'Group By' button, and enter the field name. The array is reorganized into an object where each key is a unique field value.

Can I group by nested fields?

Currently grouping works on top-level fields of each object in the array. For nested grouping, use the Flatten option first to bring nested keys to the top level.

Does my data leave my browser?

No. All processing is 100% client-side.

What is the output format of Group By?

The output is a JSON object where each key is a unique value of the grouping field, and each value is an array of matching records.

Can I reverse a Group By operation?

Yes — flattening the grouped object back into an array can be done with a simple JSONPath query or by using the Flatten/Unflatten options in the Convert tab.

What is JSON group-by?

JSON group-by organizes an array of objects into groups based on a specified field value. The result is an object where each unique value becomes a key, and its value is an array of matching objects. This is equivalent to SQL GROUP BY and is essential for data analysis, reporting, and building hierarchical views from flat datasets.

This tool groups JSON arrays by any field, including nested fields via dot notation. For example, grouping orders by "status" produces separate arrays for "pending," "shipped," and "delivered." The output is a valid JSON object ready to use in visualizations, table views, or further processing.

Group an array by a field
Input
[
  {"name":"Alice","dept":"eng"},
  {"name":"Bob","dept":"sales"},
  {"name":"Charlie","dept":"eng"}
]
Output
{
  "eng": [
    {"name":"Alice","dept":"eng"},
    {"name":"Charlie","dept":"eng"}
  ],
  "sales": [
    {"name":"Bob","dept":"sales"}
  ]
}

Get the most out of this tool

Ready to group your JSON data?

Free forever. No signup. Instant results.

Open JSON Group By Tool

JSON grouping for data analysis

Group-by is one of the most fundamental data aggregation operations, familiar from SQL's GROUP BY clause and Python's itertools.groupby() function. Applied to a JSON array, group-by takes a field name as the grouping key and produces an object where each unique value of that field becomes a key, and the corresponding value is an array of all elements that had that key value. This transforms flat list data into categorized, summarized form.

The transformation from an array to a grouped object changes the data structure fundamentally. An input of [{status: "active", name: "Alice"}, {status: "inactive", name: "Bob"}, {status: "active", name: "Carol"}] grouped by "status" produces {active: [{name: "Alice"}, {name: "Carol"}], inactive: [{name: "Bob"}]}. The groups are immediately usable for rendering categorized UI, computing counts per category, or passing to chart libraries.

Counting elements per group is the natural follow-on to grouping. After grouping, each group's length gives the count for that category. This is the equivalent of SELECT status, COUNT(*) FROM users GROUP BY status in SQL. The count-per-group pattern is ubiquitous in dashboards, analytics tools, and reporting systems — and it is trivially achievable from the grouped JSON output by mapping each group array to its length.

Multi-level grouping (GROUP BY two fields) produces nested grouped objects. Grouping orders first by year, then by month, produces {2024: {January: [...], February: [...]}, 2025: {January: [...], ...}}. This hierarchical structure maps naturally to multi-level UI components like accordion trees or nested tabs. Each level of nesting corresponds to one grouping dimension.

Aggregations within groups — sum, average, min, max of a numeric field — are common needs alongside grouping. GROUP BY status followed by SUM(amount) gives the total amount per status. While this tool provides the grouping operation, computing aggregations from the grouped result is straightforward: each group array can be reduced to its sum with array.reduce((acc, item) => acc + item.amount, 0) in JavaScript or similar in any language.

JSON grouping is particularly useful when you receive flat API responses that need hierarchical rendering. A list of log entries grouped by date produces a timeline view. A list of products grouped by category produces a catalog view. A list of transactions grouped by merchant produces a spending analysis view. These UI patterns all start with grouping the flat API response by a categorical field.

When developers use this tool

Dashboard data preparation Group flat API response data by category, status, or date before passing to chart libraries. The grouped structure is directly compatible with bar chart, pie chart, and grouped timeline data formats.
Generating category counts Count how many items exist in each category by grouping and reading group array lengths. This gives you the SQL equivalent of GROUP BY COUNT(*) without writing a database query or backend endpoint.
Building select option lists Group a list of items by a parent category to build cascading select dropdowns. The grouped object gives you the parent options as keys and the child option arrays as values, ready for rendering.
Data exploration and analysis When exploring an unfamiliar dataset, group by different fields to understand the distribution of values. This reveals the cardinality of categorical fields and helps you understand the data's structure before writing transformation code.

Additional frequently asked questions

What does the output look like after grouping?

The output is a JSON object where each key is a unique value of the grouping field, and each value is an array of the input objects that had that field value. For example, grouping [{type:"a",x:1},{type:"b",x:2},{type:"a",x:3}] by "type" produces {"a":[{type:"a",x:1},{type:"a",x:3}],"b":[{type:"b",x:2}]}.

What happens if a record is missing the grouping key?

Records missing the grouping field are grouped under a special key — typically "undefined" or "null". This ensures no records are silently dropped during grouping. You can then inspect the null group to identify records with missing data and decide how to handle them in your application logic.

Can I group by a nested field?

Yes, using dot notation for the key path. Specify "address.city" as the grouping key to group by the city field inside the nested address object. The tool resolves the nested path for each element and uses the resolved value as the group key. Records where the nested path does not exist are grouped under the null/undefined bucket.

Is grouping the same as indexing?

Grouping and indexing are similar but different. Group-by produces a one-to-many mapping: each key maps to an array of matching elements. Indexing (e.g., keying by a unique ID field) produces a one-to-one mapping where each key maps to exactly one element. Indexing is useful for lookup; grouping is useful for aggregation and categorization.