JSON Validator & Auto-Repair
Check JSON for syntax errors and repair comments, single quotes, unquoted keys and trailing commas. Values stay as typed; errors show your line and column. How it works
Use the JSON Validator & Auto-Repair
0 of 200,000 characters (longer text is not checked)
About the JSON Validator & Auto-Repair
This validator repairs four kinds of syntax error: // and /* */ comments, single-quoted strings, unquoted object keys and trailing commas. It also strips a Markdown code fence, with any prose around it, from JSON copied out of a chat answer. It changes nothing else: numbers keep their exact digits, key order and duplicate keys stay, and an error that cannot be repaired is reported at the line and column of the text you pasted.
What the repair does to each kind of mistake
| Input | Repaired text or error |
|---|---|
| {a: 1} | {"a": 1} |
| {'a': 'b'} | {"a": "b"} |
| {"a": 1,} | {"a": 1} |
| [1, 2, 3,] | [1, 2, 3] |
| {"a":/* n */1} | {"a": 1} |
| {'note': 'a /* b */ c'} | {"note": "a /* b */ c"} |
| {"id": 12345678901234567890} | {"id": 12345678901234567890} |
| {a: 1, 2b: 2} | Unexpected "2". This is not valid JSON, and the automatic repairs could not fix it. (line 1, column 8) |
| {"a": 1 | Missing closing bracket: the text ends with 1 open bracket. Nothing was added. Adding } at the end would complete it. (line 1, column 8) |
Each cell is the repaired text the tool returns, or for an error its message followed by the line and column the page shows beside it. A comment-like sequence inside a string is kept, and the large integer keeps all its digits. For the cut-off object, the Add closing brackets button turns {"a": 1 into {"a": 1}.
How to use this tool
- Paste JSON, or JSON-like text, into Input JSON. Load Sample (with errors) fills in a broken example.
- Press Validate & Repair, or turn Auto-validate on (it starts off) to check 600 ms after each pause in typing.
- Read the badges: comments removed, quotes fixed, keys quoted, trailing comma and code fence removed, each with a count.
- If the text was cut off, the error says which brackets are missing; press Add closing brackets to append them.
- Choose Formatted or Minified, and Raw or Tree, then copy the output. For an error, press Jump to error to select the character in your text.
Frequently asked questions
- How do I fix invalid JSON?
- Paste it and press Validate & Repair. Comments, single-quoted strings, unquoted keys and trailing commas are repaired and counted, and a Markdown code fence is stripped. Text that stops early, such as {"a": 1, is reported as a missing closing bracket with an Add closing brackets button. For any other mistake, such as a missing comma, the tool reports where it found the problem in your text and leaves the fix to you.
- Can it fix JSON copied from ChatGPT or another chat answer?
- Yes, when the JSON sits in a Markdown code fence: the line of three backticks (with or without json after it), the closing backticks and any sentences before or after them are removed as one repair, and the badge reads 1 code fence removed. If the answer was cut off mid-object, Add closing brackets closes an open string first, then each open bracket, innermost first: [1, [2 becomes [1, [2]].
- Are comments, single quotes and trailing commas valid JSON?
- No. RFC 8259 defines a string as text between double quotation marks, puts commas only between members and defines no comment syntax. JavaScript accepts all three, which is why JSON copied from code often needs this repair.
- Does the repair change my numbers or key order?
- No. The output is the repaired text itself, never rebuilt from parsed values, so 12345678901234567890 keeps its digits (JSON.parse in a browser would give 12345678901234567000) and keys stay in the order you wrote. Duplicate keys stay in the text and are reported, because JSON.parse would keep only the last value.
- Why does it say the text is not valid after repairs?
- The mistake is outside the four repairs. A key that starts with a digit or holds non-ASCII letters is not quoted, and a missing comma or colon, a bracket missing in the middle or a stray character is not guessed at. The error names the character and shows its line and column in your original text, even when comments before it were removed.
- How much text can it check?
- The cap is 200,000 characters and 1,000 levels of nesting, so a large log export may need splitting. Longer or deeper text is refused with a message that gives the size. Text whose 2-space indented form would pass 5,000,000 characters is refused too.
Related Tools
View all toolsYAML Validator
Check YAML syntax as you type: line and column of the first error, a JSON view of each document, unknown tags such as !Ref listed, << merge keys optional.
Cron Expression Explainer
Paste a 5-field cron expression or an @alias to read it as one sentence, a card per field and its next runs: 0 9 * * 1 runs at 9:00 AM on Monday.
JS Object to JSON Converter
Paste a JavaScript object or array literal and get JSON. Unquoted keys, single quotes and trailing commas are accepted, and no code is run.
JSON Diff
Compare two JSON documents side by side or as a list of paths, such as $.name changed from "John" to "Jane". Key order is ignored; numbers compare exactly.
JSON Formatter
Paste JSON to format it with 2 spaces, 4 spaces or tabs, minify it or sort its keys. A syntax error is reported with its line, column and a caret under it.
JSON Path Query Tool
Test a JSONPath expression on your JSON and see the match count, each matching value and its path. Filters such as ?(@.price < 10) work. Up to 100 KB.