How to Validate and Repair Invalid JSON Syntax
Published
Diagnose and fix JSON syntax errors: RFC 8259 compliance, line and column coordinate pinpointing, trailing commas, single quotes, and 1-click auto-repair.
Quick answer
To validate JSON, check whether text strictly conforms to the IETF RFC 8259 specification: property keys and strings must use double quotes, items must be comma-delimited, enclosures (braces {} and brackets []) must match, and comments or trailing commas are disallowed. When errors occur, parse with a tokenizing scanner to compute exact line and column numbers. You can diagnose multi-error payloads and automatically fix syntax flaws in one click using our free client-side JSON Validator.
5 common JSON syntax errors & how to fix them
1. Trailing commas
A comma placed before a closing bracket or brace is the most frequent syntax mistake. Valid in JavaScript and Python, but strictly forbidden in RFC 8259 JSON.
// INVALID
{ "name": "API", "version": 2, }
// VALID
{ "name": "API", "version": 2 }
2. Single-quoted strings and keys
JSON strictly mandates double quotes (") for strings and dictionary keys. Single quotes (') produce an Unexpected token error.
// INVALID
{ 'status': 'success' }
// VALID
{ "status": "success" }
3. Unquoted property keys
JavaScript object literals allow unquoted keys, but JSON requires double-quoted identifiers.
// INVALID
{ port: 8080, host: "localhost" }
// VALID
{ "port": 8080, "host": "localhost" }
4. Comments (single-line or multi-line)
Standard JSON does not support comments (// or /* */). While JSONC and JSON5 permit comments, strict JSON parsers will fail on the first comment token.
// INVALID in RFC 8259
{
// Port configuration
"port": 8080
}
// VALID in RFC 8259
{
"port": 8080
}
5. Python literals (True, False, None)
When copying debug output from Python logs, dictionaries often include Python capitalization:
// INVALID
{ "debug": True, "cache": None }
// VALID
{ "debug": true, "cache": null }
Pinpointing errors with line and column coordinates
Basic tools run JSON.parse(), which aborts upon finding the first error and leaves you to search through millions of characters manually.
Our JSON Validator runs a full tokenizing scanner in a local Web Worker:
- It parses the entire document in a single pass.
- It detects all syntax errors simultaneously, not just the first one.
- It outputs precise line and column coordinates with clickable “Jump to Error” navigation that centers your cursor directly on the broken character.
1-Click automated syntax repair
Rather than hand-editing dozens of trailing commas and single quotes across an exported file, our auto-repair engine safely normalizes:
- Stripping illegal trailing commas.
- Converting single-quoted strings and keys into compliant double quotes.
- Wrapping unquoted object keys in double quotes.
- Stripping single-line and multi-line comments.
- Converting Python literals (
True,False,None) to standard JSON (true,false,null).
All processing occurs in your browser; confidential API payloads, database dumps, and credentials are never sent to external servers.
Programmatic validation in Python
import json
raw_text = '{"name": "production", "active": true}'
try:
data = json.loads(raw_text)
print("Valid JSON document")
except json.JSONDecodeError as err:
print(f"JSON syntax error at line {err.lineno}, column {err.colno}: {err.msg}")
Related tools & guides
- JSON Validator Online: Validate syntax against RFC 8259 and auto-repair errors.
- JSON Formatter & Tree Viewer: Beautify and inspect validated payloads.
- How to Format and Beautify JSON: Indentation options and key sorting.
- JSON to CSV Converter: Convert validated JSON payloads into CSV spreadsheets.