Fix Invalid JSON
Paste broken JSON on the left, press Fix JSON, and get valid, parseable JSON on the right. The tool automatically repairs trailing commas, single quotes, comments, unquoted keys, smart quotes and more, and tells you exactly what it changed in plain English.
Why does JSON break?
JSON looks a lot like a JavaScript object, but it is far stricter. The most common reasons pasted text fails to parse are:
- Trailing commas after the last item in an object or array, usually left behind when a line is deleted.
- Single quotes around strings or keys, which are valid in JavaScript but not in JSON.
- Comments (
//or/* */), copied from config files or code samples. Standard JSON has no comments. - Unquoted keys like
{ name: "Ada" }instead of{ "name": "Ada" }. - Smart quotes pasted from Word, Google Docs, emails or chat apps, which look like quotes but are different characters.
- Truncated output from APIs or AI models that cut off mid-response, leaving brackets unclosed.
Formatters and validators only tell you where the error is. This tool goes further and repairs the damage for you.
Frequently asked questions
What kinds of broken JSON can this tool fix?
It repairs trailing commas, single-quoted strings and keys, // and /* */ comments, unquoted object keys, smart/curly quotes, raw line breaks inside strings, leading zeros (007), missing leading zeros (.99), invalid values like undefined, NaN and Infinity (converted to null), and unclosed brackets from truncated input. After repairing, it verifies the result with a real JSON parse.
Is my data sent to a server?
No. Everything runs 100% client-side in your browser using plain JavaScript. Pasted JSON never leaves your device, there is no account, no upload and no tracking of your content.
What if my JSON cannot be repaired?
Some damage is beyond automatic repair, for example a string cut off mid-word with no recoverable structure, or two values with a missing comma between them. In that case the tool shows the exact parser error message so you know precisely what to fix by hand.
Does it handle JSON with comments (JSONC)?
Yes. Both single-line // comments and multi-line /* */ comments are stripped before parsing, as long as they appear outside of string values. URLs inside strings are left untouched.
Can I get the output minified instead of pretty-printed?
Yes. After a successful repair, use the Minify toggle above the output to switch between human-readable (2-space indent) and compact single-line JSON. The Copy button copies whichever view is active.
Pro features
API access and batch mode for repairing thousands of JSON documents at once are on the roadmap. The free web tool above will always stay free.
Privacy note
This page contains no trackers on your pasted content and makes zero network requests for the repair itself. Your JSON is processed entirely in your browser and never leaves this device.
Guides
How to Handle Dates in JSON: Why JSON.parse Gives You a String, Not a Date
How to handle dates in JSON: JSON has no date type, so stringify writes ISO 8601 strings and parse hands back strings. The reviver fix, the midnight UTC trap, and the format rule that prevents both.
Read our JSON guides
Why Your JSON Is Double Encoded (Stringified Twice) and How to Fix It
Your JSON parses to a string full of backslashes instead of an object. That is double encoding: JSON.stringify ran twice. How to spot it, undo it, and stop it at the source.
Fix JSON Trailing Comma Error in VS Code settings.json: Why It Passes There and Fails Everywhere Else
Fix JSON trailing comma errors in VS Code settings.json: why settings.json tolerates them under JSONC while strict JSON parsers reject them, and how to catch the error before it ships.
Why JSON.stringify Drops Undefined and Functions (and the Replacer Fix)
Why JSON.stringify removes undefined and functions: JSON has no way to write them, so object properties vanish and array items become null. The replacer fix, and the PATCH trap to watch for.
How to Fix JSON Unquoted Keys: You Pasted JavaScript, Not JSON
Every key in JSON must be a double-quoted string. The error messages, the regex fix and its traps, and the serializer-first rule.
How to Fix NaN and Infinity in JSON (and Stop JSON.parse Failing)
JSON.parse rejects NaN and Infinity because JSON has no such values. The null, string, and replacer fixes, and the Python allow_nan trap.
How to Fix Truncated JSON From AI Output
Your LLM call returned JSON that stops mid-string. Token limits, the finish_reason check, and why closing the brackets is not always the right fix.
Bad Escaped Character in JSON: Why Your Regex Breaks the Parser
How to fix the JSON parse error "bad escaped character in JSON": JSON allows only eight escapes plus unicode, so \d, \w, \U and \x all fail. Where bad escapes hide and the serializer-first fix.
Smart Quotes in JSON: Why Your Parser Chokes on Curly Quotes
The fix for smart quotes curly quotes breaking your JSON parse error: why U+201C looks like a real quote, the four code points to replace, and the normalize pass that ends it.
How to Fix "Do Not Know How to Serialize a BigInt" in JSON.stringify
The value arrived as a BigInt, usually a database id. Find the key, then pick from three fixes: convert at the source, use a replacer, or patch toJSON.
How to Fix Python's JSONDecodeError: Expecting Value at Line 1 Column 1
The parser wanted a value at character 0 and found nothing it could use. The four real causes (empty input, HTML instead of JSON, a BOM, the wrong file) and the safe-parse pattern that ends it.
Unexpected Non-Whitespace Character After JSON: What It Means and How to Fix It
JSON.parse finished one value and found extra text: two objects pasted together, JSON Lines parsed whole, or trailing prose. The position number names the intruder; the fix depends on the case.
Unexpected Token '<' in JSON at Position 0: Your API Returned HTML, Not JSON
The < at position 0 means the response is HTML: an error page, a wrong URL, or expired auth. The three causes and the check-before-you-parse fix.
Fixing the JSON BOM Byte Order Mark Parse Error: An Invisible Character at Position 0
JSON.parse fails at position 0 in a file that looks valid. The invisible U+FEFF byte order mark, where it comes from, and the one-line strip.
JSON5 vs JSON: What JSON5 Allows That Strict JSON Rejects
Comments, trailing commas, unquoted keys, single quotes, hex numbers. What JSON5 relaxes, the one-direction rule, and when to convert back to strict JSON.
Unexpected Token 'o' in JSON at Position 1: You Parsed an Object, Not a String
The letter o is the second character of [object Object]. You parsed something already parsed. The three ways it happens and the one-line fix.
JSON Duplicate Keys: Which Value Is Used, and Which One You Lose
Duplicate keys parse fine and quietly keep only the last value. Where they come from, why a reviver can't catch them, and the copy-paste check that does.
Unexpected Token 'u' in JSON at Position 0: You Parsed the Word "undefined"
The parser saw the letter u because the value was undefined. Where undefined values sneak in, and the safeParse helper that ends this error for good.
"Unexpected End of JSON Input": Empty Body, Cut-Off Payload, or Unclosed Bracket
The parser reached the end while still waiting for a value. The three real causes: an empty response body, a truncated response, or hand-written JSON with a missing closer.
Why Does JSON Round Large Numbers? The 2^53-1 Precision Trap, Fixed
The digits are exact in the text. The rounding happens in the JavaScript Number past 9,007,199,254,740,991. How to spot it and fix it.
How to Fix the JSON Missing Comma Error (It Points at the Wrong Line)
The parser reports the spot where it gave up, not where you slipped. The comma goes at the end of the line above.
How to Fix "Converting Circular Structure to JSON" in JavaScript
The error names the property that closes the loop. Where circular references hide, the one copyable replacer fix, and the four real options ranked.
Bad Control Character in String Literal: The Invisible Newline That Breaks JSON
The error reads "position 26" and position 26 looks empty. Where invisible newlines and tabs hide inside strings, and the one repair rule that escapes them.
Fixing Unescaped Quotes in JSON String Values (the Error That Points at the Wrong Spot)
Your parser blames position 205. The real culprit is an unescaped quote inside a string value, sixty characters earlier. The one repair rule that finds it every time.
How to Fix the JSON Single Quotes Error (Python Dicts, LLM Output, Apostrophes)
Where single-quoted "JSON" comes from, and how to fix it without breaking apostrophes.
The Trailing Comma That Breaks Your JSON (And the 30-Second Fix)
Why "Unexpected token }" points at an innocent line, and how to stop trailing commas for good.
NDJSON Broke My Parser: How to Fix JSON Lines Errors
Why JSON.parse fails on .jsonl files, the four line-based mistakes, and a copy-paste fix that reports line numbers.
Why Is My JSON Invalid? The 7 Syntax Errors That Break JSON.parse
Trailing commas, single quotes, smart quotes, comments, and the other repeat offenders, with before-and-after examples for each.
JSON with Comments (JSONC): What It Is and How to Handle It
Where JSONC is safe, where it breaks parsers, and how to strip comments without a regex destroying your URLs.