Home → JSON Array Operations

JSON Array Operations

Filter, sort, group, and deduplicate JSON arrays without writing code.

About This Tool

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.

JSON Array Operations Explained

Arrays are a core JSON data type and often require manipulation — sorting, filtering, deduplicating — before the data is ready to use.

Sorting JSON Arrays

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

Filtering JSON Arrays

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.

More Array Operations

Beyond sort and filter, the tool supports structural transformations that prepare arrays for downstream use.

Deduplicating Arrays

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.

Grouping and Aggregating

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.

Frequently Asked Questions

What array operations does this tool support?+
The tool supports sorting (by any key, ascending or descending), filtering (keep or remove elements matching a condition), deduplication (remove duplicate entries by key or full value), reversing array order, slicing (extract a subrange), flattening nested arrays, and grouping elements by a shared key.
How do I sort a JSON array of objects by a specific key?+
Enter your JSON array, select the Sort operation, type the key name you want to sort by (such as 'price' or 'created_at'), and choose ascending or descending order. The tool handles numeric sorting correctly and can sort by nested keys using dot notation.
Can I chain multiple array operations?+
Yes. Apply one operation, copy the result, and paste it back as input to apply the next operation. For example, filter an array first, then sort the filtered result, then deduplicate. Chaining lets you build complex transformations step by step.
Is the JSON array operations tool the same as JSONPath?+
They overlap but serve different purposes. JSONPath is a query language for extracting values. The array operations tool provides GUI-driven transformations specifically for arrays: sort, filter, deduplicate, and group. For complex queries, JSONPath is more powerful; for common array manipulations, this tool is faster.

JSON Array Operation Reference

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.

Core Array Operations

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]

Advanced: Group By Field

// 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] }

jq Array Operations

# 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

JSON Array Operations Reference

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
SortOrder by field ascending/descending[{age:30},{age:25}] → [{age:25},{age:30}]
FilterKeep matching elements[{active:true},{active:false}] → [{active:true}]
MapTransform each element[{price:10}] → [{price:11}] (after +10%)
FlattenRemove array nesting[[1,2],[3,4]] → [1,2,3,4]
UniqueRemove duplicates[1,2,2,3] → [1,2,3]
Group byGroup into bucketsGroup users by role
SliceTake a range[0,1,2,3,4][1:3] → [1,2]
ReverseFlip order[1,2,3] → [3,2,1]
CountCount matching elementsCount active users

Array Operations in JavaScript

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));