JSON array distinct by
json-array-distinct-by · version 1.0.0 · JSON & JSONL · free, no key needed
Deduplicate a JSON array of objects based on specific keys.
Use when you need to: json array distinct by · dedupe json array · unique json objects by key.
Supported
- json array distinct by
- dedupe json array
- unique json objects by key
Not supported
- fuzzy deduplication
- complex expression unique
Behavior
- Outputs a new array containing only the first object encountered for each distinct combination of the specified keys.
- Follows the original array ordering for the kept objects.
- Missing or null keys are grouped together and treated as the string 'undefined' or 'null'.
Input
array(array of object, required): max items 10000keys(array of string, required): min items 1; max items 32; each min length 1
Output
result(array of object, required)count(integer, required)
Limits
- max array items: 10000
- max output items: 10000
- max keys: 32
Example
Request input:
{
"array": [
{
"id": 1,
"v": "A"
},
{
"id": 1,
"v": "B"
},
{
"id": 2,
"v": "C"
}
],
"keys": [
"id"
]
}
Response:
{
"result": {
"result": [
{
"id": 1,
"v": "A"
},
{
"id": 2,
"v": "C"
}
],
"count": 2
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "json-array-distinct-by",
"version": "1.0.0",
"input": {
"array": [
{
"id": 1,
"v": "A"
},
{
"id": 1,
"v": "B"
},
{
"id": 2,
"v": "C"
}
],
"keys": [
"id"
]
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/json-array-distinct-by/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"array":[{"id":1,"v":"A"},{"id":1,"v":"B"},{"id":2,"v":"C"}],"keys":["id"]}'
The machine-readable contract is at /v1/tools/json-array-distinct-by/versions/1.0.0.
CLI
node cli.mjs run json-array-distinct-by 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- JSON array filter equals: Filter JSON array objects where a key equals a specific value.
- JSON array group by: Group an array of JSON objects by exact keys.
- JSON array index by: Convert an array of objects into a single object indexed by a specific key.
- JSON array sort objects: Stably sort an array of objects by explicit string keys using UTF-16 lexicographic order.
- JSON array unique: Deduplicate a JSON array by structural equality, keeping first-seen order.
- JSON array anti join: Anti join two JSON arrays of objects on exact keys.