How to fix invalid JSON

Invalid JSON usually comes down to a short list of syntax mistakes. If you work through them in order, you can repair most broken payloads in under a minute.

Start with validation, not guesswork

When a payload fails, the first goal is not to make it pretty. It is to confirm that the JSON is actually invalid and then narrow down the syntax issue. Use JSON Validator or Fix Invalid JSON to check the payload before editing.

Step 1: Look for the common mistakes first

Most invalid JSON errors are caused by a small group of problems:

  • Trailing commas after the last item in an array or object.
  • Single quotes instead of double quotes.
  • Missing closing braces or brackets.
  • Unquoted keys copied from JavaScript object syntax.
  • Comments pasted into a JSON block.

Step 2: Repair the payload in small passes

Do not rewrite the entire object at once. Fix one syntax issue, validate again, and repeat. That approach is faster than making several guesses and losing track of what changed.

Example: trailing comma

{
  "user": "Ada",
  "roles": ["admin", "editor",]
}

Remove the final comma after "editor" so the array closes cleanly.

Example: single quotes

{ 'name': 'Ada' }

JSON requires double quotes:

{ "name": "Ada" }

Step 3: Format the repaired JSON

Once the payload validates successfully, run it through JSON Formatter. Pretty printing makes it easier to confirm nesting, compare changes, and reuse the result in code or docs.

Step 4: Check your workflow context

If the JSON came from a request body, log file, or copied example, ask why it became invalid in the first place. Did someone paste JavaScript object syntax into a JSON field? Did a log line cut off the final brace? That context can prevent the same bug from coming back.

Privacy note: Runs locally in your browser. Your JSON is not uploaded.

Related JSON tools

FAQ

What is the first thing to check in invalid JSON?

Start with commas, quotes, brackets, and comments. Those are the most common sources of failure.

Why can JavaScript-looking data still be invalid JSON?

Because JSON is stricter than JavaScript object syntax. Keys must be quoted and trailing commas are not allowed.

Should I format the JSON before fixing it?

Only after it validates. Formatting requires valid JSON, so repair the syntax first.

Where can I practice this workflow?

Use Fix Invalid JSON and JSON Validator directly in the browser.