Group and Aggregate a JSON Array
A GROUP BY for a JSON array, without loading it anywhere. Pick the field that defines the groups, pick what to do with the rest, and get one object per group. Every result carries a count alongside your chosen aggregate — because the count is what tells you whether a striking average is a real trend or one record pretending to be one.
How to group a JSON array
- Paste a JSON array of objects.
- Name the grouping field. Comma-separate for a multi-level group —
region,monthgives one object per region-and-month pair. - Choose the aggregate and the field it applies to. Count records needs no field.
- Sort by the result to put the largest groups first, which is usually the question you actually had.
- Pick the output shape: an array is easier to feed onward, an object keyed by group is easier to look things up in.
How the numeric aggregates treat non-numbers
Sum, average, min, max and median skip any value they cannot read as a number — nulls, missing fields,
"N/A", objects. They do not fail and they do not substitute zero. The consequence is worth
internalising: an average over a field that is half missing is the average of the half that was present, not of
every record in the group. The count field is always the full record count, so a large gap between
it and what you expected to be averaged is your signal that something is absent.
Values arriving as numeric strings are handled — "1,234" and "1234" both read as
1234 — because that is how spreadsheet exports arrive. Currency symbols are not; strip them first with
Filter array or upstream.
The non-numeric aggregates
Count distinct answers "how many different values does this group hold" — distinct products per order, distinct users per tenant. Collect and collect distinct gather the values into an array, turning a one-row-per-tag shape into a one-object-per-item shape with a tag list; that is the inverse of exploding an array into rows. Keep the whole records nests every original object under its group, which is the right choice when the grouping is a step rather than the answer.
Privacy
Nothing is uploaded. The grouping runs in this tab using your own browser's JavaScript engine — no server sees your data, and the page keeps working with the network disconnected.
FAQ
Can I compute two aggregates at once?
Not in one pass. Run it twice — once for sum, once for average — and merge the two results with Deep merge, or use keep the whole records and compute both downstream.
Are group values case-sensitive?
Yes — UK and uk are two groups. Normalise first with Convert key case for keys, or a find-and-replace for values, and check the result with a count-only pass.
What happens to records missing the grouping field?
They collect into a group whose key is the empty string, so nothing is silently dropped. If that group is large, the field is not the categorical one you thought it was.
Why does my sum have a long decimal tail?
Floating-point arithmetic. Results are rounded to ten decimal places to suppress the worst of it, but money is best summed in integer minor units. See Number precision for what JSON parsing does to large numbers.