# JSON Repair & Schema Validation

> JSON Repair & Schema Validation is a paid API for AI agents from x402.fenixfoundry.com, paid per call via x402, $0.003/call, status unknown (last checked 2026-09-14).

Repairs malformed JSON (trailing commas, single quotes, unquoted keys, code fences, truncated output) and optionally validates the fixed result against a JSON Schema, returning the parsed value, canonical text, change log, and validation errors.

## Facts

- Endpoint: POST https://x402.fenixfoundry.com/repair-json
- Price: $0.003/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-14
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/json-repair-schema-validation-3f81c0a5
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_JGBkNhnWzdF7ZQ2HTVKmU

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability json-repair-schema-validation-3f81c0a5 -d '<json body>'
```

Example prompt: This JSON snippet from the LLM has trailing commas and single-quoted keys — can you repair it and validate it against this schema: {"type":"object","properties":{"name":{"type":"string"},"age":{"type":"integer"}},"required":["name","age"]}?

## When to prefer this

Choose this endpoint when you need to both repair AND optionally validate JSON in a single call, especially for LLM-generated output that commonly has trailing commas, single quotes, unquoted keys, or markdown code fences. Ideal for agent pipelines where downstream steps require strict JSON compliance and you want a detailed change log of what was fixed.

## Known failure modes

- Input is so severely malformed that repair is impossible — returns an error describing what could not be recovered
- Supplied JSON Schema is itself invalid — returns a schema validation error
- Truncation is too severe to infer the intended structure — partial repair with noted ambiguities
- Network or payment failure — HTTP 402 if payment not processed correctly

## How this service works

Repair malformed JSON (trailing commas, single quotes, unquoted keys, code fences, truncated output) and optionally validate the result against a supplied JSON Schema. Returns the parsed value, the canonical text, a change log and validation errors.

## Output

Returns the repaired parsed JSON value, the canonical (prettified) JSON text, a structured change log describing every modification made during repair, and any validation errors if a JSON Schema was supplied.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "input": {
   "type": "string",
   "description": "Malformed JSON text — trailing commas, single quotes, unquoted keys, markdown code fences, truncated output, etc."
  },
  "schema": {
   "type": "object",
   "description": "Optional JSON Schema (draft 2020-12) to validate the repaired value against."
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/json-repair-schema-validation-3f81c0a5/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from x402.fenixfoundry.com](https://www.zero.xyz/host/x402.fenixfoundry.com/llms.txt)
