# JSON schema validate

`json-schema-validate` · version 1.0.0 · JSON & JSONL · free, no key needed

Validate a JSON instance against ComputeFirst Schema 1.0.

**Use when you need to: json schema validate · validate json against schema · check json instance against schema.**

## Supported

- json schema validate
- validate json against schema
- check json instance against schema
- computefirst schema validate

## Not supported

- regex patterns
- string formats
- remote $ref
- float numbers
- allOf anyOf oneOf not
- draft-2020-12 full

## Behavior

- ComputeFirst Schema 1.0 is a closed keyword subset; unknown schema keys are rejected.
- type is a single string: null, boolean, string, integer, object, or array. integer means Number.isSafeInteger; numeric strings do not match.
- const uses exact JSON equality (object key order does not matter). enum lists at most 64 such values.
- Object checks use own keys only. required names are unique and checked in listed order. additionalProperties is a boolean and defaults to true.
- items is one subschema applied to every array element. minLength and maxLength use JavaScript UTF-16 string.length.
- Validation failures are collected as {path, keyword, message} with JSON Pointer paths, DFS order, at most 100 errors.
- Non-JSON values and invalid schemas throw. The instance is not mutated. Empty schema {} matches any valid JSON value.

## Input

- `schema` (object, required)
- `instance` (any JSON value, required)

## Output

- `valid` (boolean, required)
- `errors` (array of object, required): max items 100

## Limits

- max input bytes: 256000
- max output bytes: 1048576
- max errors: 100
- max enum values: 64
- max required: 256
- max depth: 16
- max object keys: 5000
- max array items: 5000
- max properties: 5000

## Example

Request input:

```json
{
  "schema": {
    "type": "object",
    "required": [
      "name",
      "count"
    ],
    "properties": {
      "name": {
        "type": "string",
        "minLength": 1
      },
      "count": {
        "type": "integer"
      }
    },
    "additionalProperties": false
  },
  "instance": {
    "name": "Ada",
    "count": 3
  }
}
```

Response:

```json
{
  "result": {
    "valid": true,
    "errors": []
  }
}
```

## How to call it

### MCP

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

```json
{
  "id": "json-schema-validate",
  "version": "1.0.0",
  "input": {
    "schema": {
      "type": "object",
      "required": [
        "name",
        "count"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "count": {
          "type": "integer"
        }
      },
      "additionalProperties": false
    },
    "instance": {
      "name": "Ada",
      "count": 3
    }
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/json-schema-validate/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"schema":{"type":"object","required":["name","count"],"properties":{"name":{"type":"string","minLength":1},"count":{"type":"integer"}},"additionalProperties":false},"instance":{"name":"Ada","count":3}}'
```

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

### CLI

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

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

## Related tools

- [JSONL validate](/tools/jsonl-validate): Validate strict JSON Lines text and report the value count and UTF-8 byte length.
- [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 count](/tools/json-array-count): Count structural occurrences in a JSON array in first-seen order.
- [JSON array distinct by](/tools/json-array-distinct-by): Deduplicate a JSON array of objects based on specific keys.
