waynetools
JSON · LLM · client-side

LLM Structured Output Validator

Paste the raw text an LLM returned — even with ```json fences, stray prose, or a trailing comma — plus the JSON Schema you expect. This tool repairs the common formatting mistakes first, then checks the result against your schema for missing fields, wrong types, and unexpected extras. Everything runs in your browser; nothing is uploaded, ever.

Updated 2026-07-11 · Built by Wayne

Runs instantly, offline-capable, nothing leaves this tab

What this tool does

LLMs almost never return a bare, valid JSON string on the first try. They wrap it in a ```json code fence, add a sentence like "Here is the data you requested:" before it, leave a trailing comma after the last array item, or use a single-quoted string somewhere a human wrote a quick example. A plain JSON.parse() call rejects all of that with an unhelpful "Unexpected token" error and tells you nothing about whether the data actually matches the shape your code expects. This tool does two jobs in sequence: first it repairs the text into valid JSON (and tells you exactly what it changed), then it validates that repaired JSON against a JSON Schema, reporting every missing required field, every type mismatch, and every unexpected extra key with its exact path.

How to use it

  1. Paste the raw text your model returned into the Raw LLM output box, exactly as you received it — fences, prose, and all.
  2. Paste the JSON Schema you expect the model to follow into the JSON Schema box. If you don't have one yet, paste a clean example object instead and click Infer from example to generate a starting schema.
  3. Click Repair & validate.
  4. Read the Repairs applied list to see what was fixed before parsing (fences stripped, trailing comma removed, etc.).
  5. Read the Validation issues list for anything that still doesn't match your schema, each with a JSON path like $.items[2].price.
  6. Copy the Repaired JSON block once it's clean, or use the issue list to fix your prompt or your schema.

Two real examples

Example 1 — input (typical GPT-style tool response)
I've extracted the fields you asked for:

```json
{
  "name": "Ada Lovelace",
  "age": "36",
  "tags": [1, 2,],
}
```

Let me know if you need anything else!
Output
Repairs applied:
  - Stripped leading prose before the JSON
  - Stripped trailing prose after the JSON
  - Stripped ```json code fence
  - Removed trailing comma in array "tags"
  - Removed trailing comma in object

Validation issues (against schema requiring age: integer):
  - $.age — expected type "integer", got string ("36")

Repaired JSON:
{
  "name": "Ada Lovelace",
  "age": "36",
  "tags": [1, 2]
}
Example 2 — input (Anthropic-style tool_use argument, missing a required field)
{'city': 'Bogotá', 'unit': 'celsius'}
Output
Repairs applied:
  - Converted single-quoted strings to double-quoted JSON strings
  - Converted single-quoted keys to double-quoted JSON keys

Validation issues (against schema requiring city, unit, days_ahead):
  - $ — missing required property "days_ahead"

Repaired JSON:
{
  "city": "Bogotá",
  "unit": "celsius"
}

Frequently asked questions

Is it safe to paste my LLM output and schema here?+

Yes. Nothing is uploaded anywhere. All repair and validation logic runs in plain JavaScript in your own browser tab. There is no server call, no analytics on your input, and no storage. You can disconnect from the internet after the page loads and it keeps working.

What LLM JSON mistakes does the repair step fix?+

It strips markdown code fences (```json and ```), removes explanatory prose the model added before or after the JSON, deletes trailing commas in objects and arrays, converts single-quoted strings and unquoted object keys to valid JSON, and removes JavaScript-style // and /* */ comments. Each fix that was applied is listed so you can see exactly what changed.

What does the validator check once the JSON is repaired?+

It checks the repaired JSON against your JSON Schema (draft-07 / 2020-12 style): every required property is present, every property's type matches (string, number, integer, boolean, object, array, null), enum values are one of the allowed options, and — if additionalProperties is false — no extra unexpected keys exist. Each problem is reported with its exact path, like $.items[2].price.

Do I need a full JSON Schema, or can I just paste an example?+

Either works. Paste a real JSON Schema for strict validation, or paste a plain example JSON object and click "Infer schema from example" to auto-generate a schema from its shape (types and required keys), then edit it before validating.

Does this work for OpenAI, Anthropic, and MCP tool-call outputs?+

Yes. Whether the JSON came from an OpenAI structured output / function call, an Anthropic tool_use block, a Model Context Protocol tool result, or any other model, the repair and validation logic is the same: it is plain JSON checked against a plain JSON Schema, with two built-in example presets to try the tool immediately.

Why not just use JSON.parse() or a linter?+

JSON.parse() fails on the first syntax error and tells you nothing about whether the data matches the shape your application expects. A generic linter checks syntax but not your schema. This tool does three things a linter does not: it tolerates and repairs the specific mistakes LLMs make, it validates structure and types against your schema, and it points at the exact field path that is wrong so you can fix a prompt, not just a string.

What is the maximum size of JSON this tool can handle?+

There is no hard limit enforced by the tool itself since everything runs locally in your browser tab, but very large payloads (multiple megabytes) can make the browser's JS engine slow when repeatedly re-parsing on every keystroke. For typical LLM tool-call or structured-output payloads (a few KB to a few hundred KB) it is instant.