JSON repair

← All tools

Paste JSON an LLM returned and get valid JSON back. The page lists each repair it made, from a markdown fence to a cut-off bracket.

Your JSON never leaves the browser. Nothing is uploaded.

~~~
Open file…

Options

Minify is the only option stored in the URL. The JSON stays on this page.

Not repaired

What changed

Valid JSON

The preview is cut at 200,000 characters. Copy and Download include everything.

~~~

About this tool

Models often return an object wrapped in a markdown code fence, with a comment, a trailing comma, or a Python False where JSON wants false. JSON.parse rejects the whole string. This page repairs those cases in the browser and prints the fixes it applied.

If JSON.parse already accepts the text, the page only pretty-prints it and says the JSON is already valid. A leading byte-order mark is ignored in that check. Minify writes the same value with no extra spaces. Files up to 2 MB open in the page.

When the text is not valid JSON, the repairs are only these:

  • Curly quotes become straight quotes.
  • A json, javascript, or js fence is unwrapped when the inside contains an object or array. Text around that fence is dropped. Without a fence, prose before the first object or array is dropped.
  • // and /* */ comments are removed.
  • Trailing commas are removed.
  • Single-quoted strings become double-quoted JSON strings.
  • Unquoted keys are quoted.
  • Python True, False, and None become JSON. undefined, NaN, and Infinity become null.
  • An ellipsis is dropped. A key with no value is dropped. A cut-off string or bracket is closed. Text after the value is dropped.
  • A raw line break inside a string is escaped. An escape JSON does not allow is rewritten. A repeated key keeps the later value, and that is counted when the text needed a repair.

The page does not repair leading-zero numbers, hex numbers, or numbers with a leading plus. Integers above 9007199254740991 stay numbers. JavaScript rounds those on parse, so the output can show different digits. The page notes that instead of turning the number into a string. A key named __proto__ is kept as a normal key.

~~~

Read more

~~~

Free books, courses, and software

Get my programming books, course editions, and complete software.

Get the download library →