Array Operations
Sort, deduplicate, intersect, diff, chunk, and manipulate arrays.
POST
1 credit
/v1/array-ops
curl -X POST "https://devtools.toolkitapi.io/v1/array-ops" \
-H "Content-Type: application/json" \
-d '{
"operation": "intersect",
"arrays": [[1, 2, 3, 4], [3, 4, 5, 6]]
}'
import httpx
resp = httpx.post(
"https://devtools.toolkitapi.io/v1/array-ops",
json={
"operation": "intersect",
"arrays": [[1, 2, 3, 4], [3, 4, 5, 6]]
},
)
print(resp.json())
const resp = await fetch("https://devtools.toolkitapi.io/v1/array-ops", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
"operation": "intersect",
"arrays": [[1, 2, 3, 4], [3, 4, 5, 6]]
}),
});
const data = await resp.json();
console.log(data);
# See curl example
Response
200 OK
{
"result": [3, 4],
"operation": "intersect",
"count": 2
}
Try It Live
Live Demo
Response
Description
Sort, deduplicate, intersect, diff, chunk, and manipulate arrays.
How to Use
1
1. Set `operation` to the desired function (see table below). 2. Pass your arrays in the `arrays` field (some operations need 2+). 3. Add operation-specific `options` if needed.
About This Tool
Array Operations provides 10 common array manipulations via a single endpoint. Pass one or more arrays and an operation name to sort, deduplicate, intersect, diff, union, chunk, flatten, compact, reverse, or sample your data.
Works with arrays of any type — numbers, strings, objects, or mixed.
Why Use This Tool
- Deduplicate data — Remove duplicate entries from imported lists or query results
- Set operations — Compute intersections, differences, and unions across datasets
- Batch processing — Chunk large arrays into fixed-size pages for API pagination
- Random sampling — Pick random items for A/B tests or raffles
- Object sorting — Sort arrays of objects by a nested key
- Data cleanup — Compact out falsy values or flatten nested structures
Frequently Asked Questions
Can I sort an array of objects?
Yes — use `"options": {"key": "fieldName"}` to sort by a specific object property. Add `"reverse": true` for descending order.
What does compact remove?
Compact strips `null`, empty strings (`""`), `0`, and `false` from the array.
Start using Array Operations now
Get your free API key and make your first request in under a minute.