# JSON array unique

`json-array-unique` · version 1.0.0 · JSON & JSONL · free, no key needed

Deduplicate a JSON array by structural equality, keeping first-seen order.

**Use when you need to: json array unique · unique json values · dedupe json array.**

## Supported

- json array unique
- unique json values
- dedupe json array

## Not supported

- sort
- reference unique
- hash unstable

## Behavior

- Accept only JSON values: null, boolean, finite number, string, array, and plain objects.
- Reject NaN, Infinity, -Infinity, undefined, BigInt, functions, symbols, Date, Map, Set, RegExp, boxed primitives, Buffer, and sparse holes.
- Canonicalize -0 to 0.
- Objects may have null or Object.prototype; use own enumerable string keys only.
- Treat __proto__, constructor, and toString as ordinary own keys. Never mutate Object.prototype.
- Output objects must be Object.create(null). Deep-clone all returned JSON values.
- Bound walk: max depth 32, max nodes 10000, max UTF-8 JSON bytes 250KiB of the input document string if provided as text; when json is already a value, bound the walked node count and depth.
- items must be a JSON array.
- Two values are equal by the same rules as json-deep-equal.
- Keep the first occurrence. Output items are deep clones, objects null-prototype.

## Input

- `items` (array of any, required): max items 10000

## Output

- `items` (array of any, required)
- `items_in` (integer, required)
- `items_out` (integer, required)

## Limits

- max json depth: 32
- max json nodes: 10000
- max items: 10000

## Example

Request input:

```json
{
  "items": [
    {
      "a": 1
    },
    {
      "a": 1
    },
    {
      "a": 2
    }
  ]
}
```

Response:

```json
{
  "result": {
    "items": [
      {
        "a": 1
      },
      {
        "a": 2
      }
    ],
    "items_in": 3,
    "items_out": 2
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "json-array-unique",
  "version": "1.0.0",
  "input": {
    "items": [
      {
        "a": 1
      },
      {
        "a": 1
      },
      {
        "a": 2
      }
    ]
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/json-array-unique/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"items":[{"a":1},{"a":1},{"a":2}]}'
```

The machine-readable contract is at [/v1/tools/json-array-unique/versions/1.0.0](/v1/tools/json-array-unique/versions/1.0.0).

### CLI

```sh
node cli.mjs run json-array-unique 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [JSON array distinct by](/tools/json-array-distinct-by): Deduplicate a JSON array of objects based on specific keys.
- [JSON array count](/tools/json-array-count): Count structural occurrences in a JSON array in first-seen order.
- [Array to JSONL](/tools/array-to-jsonl): Serialize an array of JSON-safe values as JSON Lines text.
- [JSON array anti join](/tools/json-array-anti-join): Anti join two JSON arrays of objects on exact keys.
- [JSON array concat](/tools/json-array-concat): Concatenate multiple JSON arrays of objects into one.
- [JSON array drop keys](/tools/json-array-drop-keys): Remove specific keys from each object in a JSON array.
