LLM JSON Output Validator
Paste a JSON Schema and an LLM response to get every validation error with its JSON path and line. Code fences, trailing commas, single or curly quotes, comments and Python True/None are fixed first. Validation uses Ajv 8.20.0 (draft-07, 2019-09, 2020-12) in your browser.
How to use
- Paste the JSON Schema on the left. An OpenAI response_format wrapper with name and schema is unwrapped for you.
- Paste the model's output on the right, exactly as it came back, with any code fence or chatty text around it.
- Read the result. Each error shows its line and column (click to jump there), the JSON path and what went wrong. If the output had to be cleaned up first, the fixes are listed and the cleaned JSON is ready to copy.
How it works
The output is first parsed as it is. If that fails, the tool removes the problems models produce most often and tries again: a Markdown code fence, text before or after the JSON, a byte order mark, curly quotes, single quoted strings, // and /* */ comments, trailing commas, and Python True, False and None. Text inside strings is never changed.
The schema is checked with Ajv 8.20.0, a widely used JSON Schema validator, loaded only when you paste something. Draft 2020-12 and 2019-09 are used when the $schema field names them, otherwise draft-07. All errors are reported, not just the first.
The format keyword (email, date-time and so on) is not checked, and remote $ref links are not fetched.
Nothing you paste is saved, sent anywhere or written into the page address.
Errors LLMs make most
| Problem | Example | Fixed automatically |
|---|---|---|
| Code fence | ```json { ... } ``` | Yes |
| Text around the JSON | Sure! Here it is: { ... } | Yes |
| Trailing comma | {"a": 1,} | Yes |
| Single or curly quotes | {'a': 'b'} | Yes |
| Missing required field | {"title": "x"} | No, reported |
| Wrong type | "rating": "5" | No, reported |
| Extra field | "author": "x" with additionalProperties false | No, reported |
Getting valid output in the first place
- Use the provider's structured output mode when you can. OpenAI strict json_schema and Anthropic structured outputs constrain the model to the schema.
- Strict modes require every property in required and additionalProperties set to false. Check that your schema follows those rules.
- When you parse output from a model without strict mode, keep a cleanup step like the one here and validate before you trust the data.
FAQ
Why does my JSON fail to parse when it looks fine?
The usual causes are a trailing comma after the last item, a code fence around the JSON, or curly quotes from a chat window. The tool fixes these and lists what it changed.
Which JSON Schema drafts are supported?
Draft-07 by default, plus 2019-09 and 2020-12 when the $schema field says so.
Is my data uploaded?
No. Parsing and validation run in your browser, and the text is not stored or put in the URL.
Can I paste an OpenAI response_format object?
Yes. An object with name and schema, or with json_schema.schema, is unwrapped and the inner schema is used.