Developer

JSON Repair — Fix Invalid JSON Online Free 2026

JSON Repair automatically fixes the most common JSON errors: trailing commas before closing brackets, unquoted object keys, single-quoted strings, JavaScript-style // and /* */ comments, smart curly quotes, and unclosed brackets. Paste broken JSON below — perfect for fixing LLM output, JavaScript object literals, and manually edited config files.

Repaired JSON

How It Works

  1. Paste your broken or invalid JSON
  2. The engine scans character-by-character to apply fixes safely
  3. Review the list of repairs applied
  4. Copy the valid, formatted JSON output

JSON Repair — What It Fixes and Why It Matters

Invalid JSON is increasingly common because developers generate JSON by hand, copy it from JavaScript object literals, or receive it from language models that add non-standard syntax. Standard JSON parsers strictly enforce the spec — a single trailing comma causes the entire parse to fail. This tool uses a character-by-character scanner (not a simple regex) to safely identify and fix these issues without altering values, even when those values contain commas, quotes, or other special characters. You can then use the JSONPath Finder to explore the repaired document or the JSON Validator to confirm the output is fully valid before deploying it.

What Gets Repaired

ProblemExample (before)After repair
Trailing comma in object{"a":1,}{"a":1}
Trailing comma in array[1,2,3,][1,2,3]
Unquoted key{name:"Jane"}{"name":"Jane"}
Single-quoted string{"key":'value'}{"key":"value"}
Line comment{"a":1 // comment}{"a":1 }
Block comment{"a":/* note */1}{"a":1}
Smart quotes{“key”:“val”}{"key":"val"}
NaN / Infinity{"x":NaN}{"x":null}

Why Simple Regex Repair Fails

A naive regex approach like s/,}/}/g will incorrectly modify strings that happen to contain ,} — for example, {"msg":"Error: expected ,}"}. This tool uses a tokenizer that tracks whether each character is inside a string literal, so replacements only apply to structural (non-string) positions. This is the same approach used by professional JSON repair libraries like jsonrepair (npm) and Python's json-repair package.

LLM Output and JSON Repair

As AI-generated JSON becomes more common, repair tools are more important than ever. Language models frequently produce JSON with trailing commas (from training data that included JavaScript objects), comments (from JSONC examples), and occasionally truncated output (missing closing brackets due to token limits). This tool handles all three. If the LLM output is so malformed that automatic repair cannot produce valid JSON, the error message will tell you which structural problem remains, giving you a starting point for manual correction. See also our JSON Escape/Unescape tool if the LLM returned a JSON string value that itself contains escaped JSON.

Frequently Asked Questions

This tool repairs: trailing commas before } or ], unquoted object keys, single-quoted strings, JavaScript // and /* */ comments, smart curly quotes, and NaN/Infinity/undefined values (replaced with null). It also auto-closes unclosed brackets at end of input.

Common reasons: trailing commas (valid in JS but not JSON), unquoted keys from JavaScript object literals, smart quotes from text editors, LLM output with comments or trailing commas, and truncated responses missing closing brackets.

Yes. The repair runs entirely in your browser using JavaScript. No data is sent to any server. Your JSON never leaves your device.

If the repair engine cannot produce valid JSON, it shows the original parse error. In that case, structural issues beyond automatic repair require manual editing.

Comments