gekro
GitHub LinkedIn
AI

LLM JSON Repair

Turn a model's almost-JSON output into valid, parseable JSON - and check it against your schema

Broken samples:
 
Validate against a JSON Schema (optional)

Paste a JSON Schema. Supported keywords: type, properties, required, items, enum, additionalProperties, minimum, maximum, minLength, maxLength, pattern. Validation runs against the repaired JSON above.

As-is, no warranty. These apps are free under their listed license and run entirely in your browser. Use at your own risk — don't blame me if your PC catches fire, your dog runs away, or the math turns out wrong. Verify anything that actually matters. None of this is professional financial, medical, legal, or engineering advice.

© 2026 Rohit Burani · MIT · Built at gekro.com · View source ↗

Guide

What It Does

Language models are great at almost producing JSON. The last five percent - a trailing comma, a smart quote, a True instead of true, a markdown fence wrapped around the whole thing, an object that got cut off mid-generation - is where your parser throws and your pipeline stalls.

This tool takes that broken output and returns valid JSON. It does not patch the text with fragile regexes; it runs a forgiving recursive-descent parser that reads the malformed input, builds a real value, and serializes it back out. Because the output comes from JSON.stringify of a genuine object, it is always structurally valid.

What It Repairs

  • Markdown fences - strips a surrounding ```json ... ``` block, the single most common failure.
  • Prose around the JSON - “Here is the JSON you asked for: {…}” - skips text before the first { or [.
  • Quotes - single-quoted strings and keys become double-quoted; curly “smart” quotes are normalized.
  • Unquoted keys - { name: "x" } becomes { "name": "x" }.
  • Trailing and extra commas - [1, 2, 3,] and {,"a":1}.
  • Python and JS literals - True/False/None/NaN/Infinity/undefined are coerced to their JSON equivalents.
  • Unescaped control characters - a raw newline or tab inside a string value is escaped.
  • Comments - // and /* */ are removed.
  • Unclosed structures - a truncated object or array is auto-closed.

Each repair shows up in the “What I fixed” list so you know exactly what changed.

Schema Validation

Open the schema panel and paste a JSON Schema to check the repaired result. The validator is a deliberately small, dependency-free subset covering the keywords that matter for real tool schemas: type, properties, required, items, enum, additionalProperties, minimum, maximum, minLength, maxLength, and pattern. Errors are reported per JSON path.

Pairs naturally with the JSON Formatter (once it is valid) and JSON Schema to Tool Definition (going the other direction).

Limitations

  • It guesses. Auto-closing a truncated object or quoting a bareword is a best-effort interpretation, not a certainty. Always eyeball the result.
  • First value only. If the input contains several concatenated JSON values, it repairs the first and notes that the rest was ignored.
  • Schema subset. The validator does not implement $ref, allOf/anyOf/oneOf, format, or conditional schemas. It covers the common flat-and-nested tool-schema shape, not the full Draft 2020-12 spec.
  • Not a linter for valid JSON. If your input already parses, it is passed through and pretty-printed unchanged.

For informational purposes only. Not financial, medical, or legal advice. You are solely responsible for how you use these tools.