Home → JSON Array Operations
Filter, sort, group, and deduplicate JSON arrays without writing code.
Filter, sort, group, and deduplicate JSON arrays without writing code. This tool runs entirely in your browser — no data is ever sent to a server. Free to use, no account required.
Arrays are a core JSON data type and often require manipulation — sorting, filtering, deduplicating — before the data is ready to use.
Sort arrays of objects by any key, with ascending or descending order. Numeric sorting correctly orders 1, 2, 10 rather than the alphabetical 1, 10, 2. Sort by nested keys using dot notation (e.g., address.city).
Remove elements that do not match a condition, or keep only elements that do. Filter by key equality, numeric comparison, string contains, or regex pattern match.
Beyond sort and filter, the tool supports structural transformations that prepare arrays for downstream use.
Remove duplicate objects by key equality or full-value equality. For example, deduplicate a list of users by email address, keeping only the first or last occurrence of each duplicate.
Group array elements by a shared key to produce a grouped JSON structure — for example, grouping orders by customer ID. Optionally count or sum values within each group.
JSON arrays are the most common data structure in APIs. Mastering filter, map, sort, and reduce patterns lets you transform any dataset without a database.
const users = [
{id:1, name:"Alice", age:30, active:true},
{id:2, name:"Bob", age:25, active:false},
{id:3, name:"Carol", age:35, active:true}
];
// Filter: active users only
users.filter(u => u.active)
// [{id:1,...Alice}, {id:3,...Carol}]
// Map: extract names
users.map(u => u.name)
// ["Alice", "Bob", "Carol"]
// Sort: by age ascending
[...users].sort((a,b) => a.age - b.age)
// [Bob(25), Alice(30), Carol(35)]
// Find: first active user
users.find(u => u.active)
// {id:1, name:"Alice",...}
// Reduce: sum ages
users.reduce((sum, u) => sum + u.age, 0) // 90
// Unique values
[...new Set(users.map(u => u.active))] // [true, false]
// Group users by active status
const grouped = users.reduce((acc, u) => {
const key = String(u.active);
(acc[key] = acc[key] || []).push(u);
return acc;
}, {});
// { "true": [Alice, Carol], "false": [Bob] }
# Filter
jq '[.[] | select(.active == true)]' users.json
# Map: extract one field
jq '[.[].name]' users.json
# Sort by field
jq 'sort_by(.age)' users.json
# Group by field
jq 'group_by(.active)' users.json
# Unique values
jq '[.[].active] | unique' users.json
Explore more tools: All JSON Tools | Validator | Pretty Print | JSON Diff
The following operations cover the most common transformations applied to JSON arrays. Each can be composed with others — for example, filter first, then sort the remaining elements, then map to extract only the fields you need.
| Operation | Description | Input → Output |
|---|---|---|
| Sort | Order by field ascending/descending | [{age:30},{age:25}] → [{age:25},{age:30}] |
| Filter | Keep matching elements | [{active:true},{active:false}] → [{active:true}] |
| Map | Transform each element | [{price:10}] → [{price:11}] (after +10%) |
| Flatten | Remove array nesting | [[1,2],[3,4]] → [1,2,3,4] |
| Unique | Remove duplicates | [1,2,2,3] → [1,2,3] |
| Group by | Group into buckets | Group users by role |
| Slice | Take a range | [0,1,2,3,4][1:3] → [1,2] |
| Reverse | Flip order | [1,2,3] → [3,2,1] |
| Count | Count matching elements | Count active users |
JavaScript's built-in array methods cover all common operations without any library. The example below demonstrates filter, sort, map, group by, and finding the max value on a product array.
const products = [
{name:"A", price:10, category:"tech", inStock:true},
{name:"B", price:25, category:"home", inStock:false},
{name:"C", price:15, category:"tech", inStock:true}
];
// Filter in-stock items
const available = products.filter(p => p.inStock);
// Sort by price
const byPrice = [...products].sort((a,b) => a.price - b.price);
// Map to get names only
const names = products.map(p => p.name);
// Group by category
const grouped = products.reduce((acc, p) => {
(acc[p.category] = acc[p.category] || []).push(p);
return acc;
}, {});
// Find max price
const maxPrice = Math.max(...products.map(p => p.price));