Blogchevron_rightJSON Tools
JSON Tools

Common JSON Validation Errors and How to Fix Them

JSON validation errors are frustrating precisely because they are caused by tiny syntax details. This guide covers the most common errors and exactly how to fix each one.

April 18, 2026·7 min read

Trailing Commas

The trailing comma is the most common JSON error. Standard JSON (RFC 8259) does not allow a comma after the last item in an array or object. JavaScript and JSON5 allow trailing commas, which confuses developers who write JSON as if it were JavaScript object syntax.

Fix: Remove the comma that appears before the closing } or ] bracket. In large files, search for ",}" and ",]" to find all occurrences. If your source is JavaScript code, use JSON.stringify() to produce valid JSON rather than writing it by hand.

Single-Quoted Strings

JSON requires all strings — both keys and values — to use double quotes. Single-quoted strings are valid in JavaScript but not in JSON. This error frequently appears when JSON is written by developers accustomed to Python or JavaScript shorthand.

Fix: Replace all single quotes around string values with double quotes. If the string content contains double quotes, escape them with a backslash: "He said \"hello\"". A search-and-replace in a text editor can handle most cases, but be careful not to replace single quotes inside string values.

Unquoted or Incorrectly Quoted Keys

In JSON, every key must be a double-quoted string. Unquoted keys like { name: "Alice" } are valid JavaScript but invalid JSON. This error is common when copying object literals from JavaScript source code and expecting them to work as JSON.

Fix: Wrap every key in double quotes: { "name": "Alice" }. If you have a large file with many unquoted keys, a regex replacement can automate the conversion. Alternatively, convert the JavaScript object to JSON using JSON.stringify() in your browser console.

Comments and Other Non-Standard Additions

Standard JSON does not support comments. Neither // single-line comments nor /* */ block comments are part of the JSON specification. This is one of the most complained-about limitations of JSON and the primary motivation for the JSON5 format.

Fix: Remove all comments before feeding the data to a JSON parser or validator. If your use case genuinely requires comments in JSON-like files (configuration, for example), switch to JSON5 or YAML — both support comments natively.

Try JSON Validator Free Online

No sign-up required. 100% client-side — your data never leaves your browser.

Open JSON Validatorarrow_forward

Frequently Asked Questions

Why does JavaScript accept JSON that fails validation?

JavaScript object syntax is a superset of JSON — it allows trailing commas, unquoted keys, and single-quoted strings. JSON is a stricter subset designed for cross-language data interchange.

What does "Unexpected token" mean in a JSON error?

It means the parser encountered a character it did not expect given what it had already read. This usually points to a missing comma, an extra bracket, or an incorrect quote type near the reported position.

Is there a tool that auto-fixes JSON errors?

Some online tools offer a "Fix JSON" or "Repair JSON" mode that corrects common issues like trailing commas and single quotes. These are useful for one-off fixes but should not replace proper validation in a production pipeline.

Common JSON Validation Errors and How to Fix Them