Structured Output Validator
Validate AI JSON output against a JSON Schema: parse errors with line/column, plain-language fixes.
How it works
Paste a JSON Schema (or an OpenAI/Anthropic/MCP wrapper around one) and the model's output. The tool extracts the JSON from markdown code fences or surrounding prose, reports syntax errors with exact line and column, validates against a draft 2020-12 subset (types, required, additionalProperties, enum, const, ranges, lengths, patterns, items, anyOf/oneOf/allOf, local $ref and more) with human explanations and hints for typical LLM mistakes, and suggests a repaired JSON only for trivial issues such as code fences or trailing commas.
- Extraction: raw JSON if the output starts with { or [; otherwise the first ```json (or JSON-looking) code fence; otherwise the first balanced {…} / […] in the prose.
- Parsing uses a strict RFC 8259 parser that reports the first error with line and column in your original text (single quotes, unquoted keys, NaN/None/True, trailing commas, unescaped line breaks are named explicitly).
- Repair is attempted only for trivial issues – removing code fences/prose and trailing commas. Anything else is reported, never guessed. Validation then runs on the repaired JSON and says so.
- Validation implements the draft 2020-12 core used by structured-output APIs: type, enum, const, properties, required, additionalProperties, patternProperties, propertyNames, min/maxProperties, items, prefixItems, contains, min/maxItems, uniqueItems, minimum/maximum (incl. exclusive), multipleOf, min/maxLength, pattern, anyOf, oneOf, allOf, not, if/then/else, dependentRequired and local $ref. format is checked for common formats and reported as a warning. Unknown keywords are listed as not checked.
- Wrappers (OpenAI response_format/json_schema, Responses text.format, function tools, Anthropic input_schema, MCP inputSchema) are unwrapped; with strict: true the OpenAI strict-mode rules (closed objects, all properties required) are checked too.
Use this tool in an app
These free programs for your browser have this tool built in, next to everything else the task needs.
-
Agentlab AI-agent & LLM workbench
Test an AI agent before release: permissions, traces, costs, citations and output checks.
Related tools
- AI Agent Tool Explorer – Index of tools AI agents can call: this site, the MCP Registry or your definitions, by capability.
- AI Tool-Call Trace Explorer – Paste an agent transcript: see every tool call in order, with errors, timings, retries and loops.
- AI Model Compatibility Explorer – Which LLMs take images, audio or files, fit your context and support tools or structured outputs?
How to use the Structured Output Validator
Validate an LLM's JSON output against your JSON Schema, find the exact line and column of parse errors, and get plain-language fixes.
What it is for
You asked a model for JSON matching a schema, and your parser choked. Model output fails in recognisable ways: a code fence and a friendly sentence around the JSON, trailing commas, numbers as strings, a capitalised enum value, an extra property nobody asked for.
Paste your schema and the raw model output. The validator pulls the JSON out of code fences or surrounding prose, parses it strictly and reports the first syntax error with line and column in your original text. It then validates against a draft 2020-12 subset (types, required, enum, ranges, patterns, additionalProperties, anyOf/oneOf, local $ref and more) and explains each violation in plain language. You can paste a bare schema or the wrapper you send to the API: OpenAI response_format, function tools, Anthropic input_schema or MCP inputSchema.
It only repairs trivial problems, namely code fences, surrounding prose and trailing commas. Everything else is reported, never guessed. Remote $ref, $dynamicRef and unevaluatedProperties are not supported and are listed as not checked.
Worked example
The first example uses an OpenAI response_format wrapper with strict: true for an order: customer, items with sku (pattern ^[A-Z]{3}-\d{4}$), qty (minimum 1) and price, plus a status enum. The model answered "Sure! Here is the order:", then a fenced JSON block with a trailing comma after the items array, then "Let me know if you need anything else."
Result: 5 schema violations (after trivial repairs). Step by step:
- Extraction: removed the `
`json` fence. The JSON starts on line 3. - Parse: a trailing comma before
]at line 8, column 3. It was fixed in the suggested repair, and validation ran on the repaired JSON. - Violations:
/items/0/price: expected a number but got the string "19.99". The model returned the number as a string./items/1/sku: "xyz-9" does not match the pattern./items/1/qty: 0 is below the minimum of 1./items/1/note: not allowed (additionalProperties: false). Allowed: sku, qty, price./status: "Paid" is not an allowed value. Did you mean "paid"?
The second example is a missing comma between two properties. The validator stops at parsing: line 3, column 3, "missing comma after the previous value?".
How to read the result
- Extraction — how the JSON was found: raw, code fence or the first balanced object in prose.
- Parse — OK, OK after repair, or the error with line, column and the offending line.
- Errors — JSON Pointer path, failing keyword, explanation and the position in your original text. The first error is in the summary.
- Suggested repair — the trivially fixed JSON, clearly labelled as a suggestion and not the model's output.
- Schema info — the wrapper detected, strict mode, unsupported keywords and strict-mode problems in the schema itself.
Tips and common mistakes
- With OpenAI strict mode, the validator also checks the schema: every object must be closed and every property required. A schema that breaks these rules fails at the API before the model even answers.
- Don't blindly use the repaired JSON in production. If the model wraps output in prose, fix the prompt or use the API's structured-output mode.
- Enum case mismatches ("Paid" vs "paid") are common. Listing the allowed values in the field description usually helps more than changing the schema.
- Paste the exact raw output from your logs. The line and column then match what you see in your own file.
FAQ
Does it fix my JSON automatically?
Only code fences, surrounding prose and trailing commas. Missing commas, single quotes or None/True are named precisely but left for you to fix.
Which JSON Schema version is used?
A draft 2020-12 subset: the keywords structured-output APIs actually use. Unknown keywords are listed as not checked rather than silently ignored.
Can I paste a function or tool definition?
Yes. OpenAI function tools, Responses text.format, Anthropic input_schema and MCP inputSchema wrappers are unwrapped automatically.
Why are only some errors shown?
Parse errors stop validation, because there is nothing to validate yet. Schema errors are listed up to the "Maximum errors listed" setting (default 50).
Guide last updated:
For scripts and AI agents
- JSON API:
POST https://structuredoutputvalidator.usefulweb.site/api/v1/calculate(same calculation as this page) - Interface description: OpenAPI 3.1 · AI guide: llms.txt
- MCP server (Streamable HTTP):
https://structuredoutputvalidator.usefulweb.site/mcp· tool namestructured_output_validator
Example request
curl -s -X POST https://structuredoutputvalidator.usefulweb.site/api/v1/calculate \
-H 'content-type: application/json' \
-d '{…see OpenAPI examples…}'