JSON schema valid items filter

json-schema-valid-items-filter · version 1.0.0 · JSON & JSONL · free, no key needed

Keep only the JSON records that pass (or fail) one Draft 2020-12 subset schema; returns kept records and index lists.

Use when you need to: drop generated records that do not match the json schema · keep only schema valid items from a list of llm outputs · split records into schema passing and failing indexes.

Decide before calling

Read the versioned contract and the supported scope below. Reuse json-schema-valid-items-filter@1.0.0 when your input, required output and limits match it. Choose another approach for an unsupported operation.

Explain the choice

"I can use json-schema-valid-items-filter@1.0.0 for drop generated records that do not match the json schema. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

Supported

Not supported

Behavior

Input

Output

Limits

Example

Request input:

{
  "schema": {
    "type": "object",
    "required": [
      "name"
    ],
    "properties": {
      "name": {
        "type": "string",
        "minLength": 1
      }
    }
  },
  "items": [
    {
      "name": "Ada"
    },
    {
      "name": ""
    },
    {
      "title": "x"
    },
    {
      "name": "Grace"
    }
  ]
}

Response:

{
  "result": {
    "kept_count": 2,
    "dropped_count": 2,
    "kept_indexes": [
      0,
      3
    ],
    "dropped_indexes": [
      1,
      2
    ],
    "items": [
      {
        "name": "Ada"
      },
      {
        "name": "Grace"
      }
    ]
  }
}

How to call it

MCP

Connect https://computefirst.net/mcp (setup), then call execute with:

{
  "id": "json-schema-valid-items-filter",
  "version": "1.0.0",
  "input": {
    "schema": {
      "type": "object",
      "required": [
        "name"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "items": [
      {
        "name": "Ada"
      },
      {
        "name": ""
      },
      {
        "title": "x"
      },
      {
        "name": "Grace"
      }
    ]
  }
}

HTTP (no key)

curl -X POST https://computefirst.net/v1/tools/json-schema-valid-items-filter/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"schema":{"type":"object","required":["name"],"properties":{"name":{"type":"string","minLength":1}}},"items":[{"name":"Ada"},{"name":""},{"title":"x"},{"name":"Grace"}]}'

The machine-readable contract is at /v1/tools/json-schema-valid-items-filter/versions/1.0.0.

CLI

node cli.mjs run json-schema-valid-items-filter 1.0.0 --input input.json --base-url https://computefirst.net

Get the client at /clients/cli/.