We use cookies to understand how DevToolsHub is used and to improve your experience. You can choose which types of cookies to allow.
Validate JSON syntax and find errors with line numbers.
Loading...
Loading...
A JSON Validator is a tool that checks whether a JSON (JavaScript Object Notation) string conforms to the official JSON syntax specification. It parses your input and reports any syntax errors it finds β complete with line numbers, column positions, and human-readable error messages so you can fix problems quickly.
JSON is the de facto standard for data interchange on the web. It's used in REST APIs, configuration files, NoSQL databases (like MongoDB), package manifests (package.json), and countless other contexts. Even a single misplaced comma or missing quote can render an entire JSON document unparseable, causing applications to crash or fail silently. A validator catches these issues before they reach production.
The most common JSON errors include trailing commas (a comma before a closing } or ]), single quotes instead of the required double quotes, missing brackets or braces, unquoted property names, and comments (which are not allowed in standard JSON, even though many developers add them out of habit). JavaScript objects allow all of these, which is why JSON that works in a .js file can fail when parsed as strict JSON.
Unlike a JSON Formatter, which reformats and pretty-prints valid JSON, a validator focuses on correctness. It tells you whether the JSON is valid and, if not, exactly where and whyit's broken. You can use a validator to check API responses, debug configuration files, verify data payloads before sending them to a server, or troubleshoot parsing errors in your code. Once your JSON is valid, you can feed it into a formatter for readability.
JSON does not allow a comma after the last element in an object or array. For example, {"a":1,} is invalid β remove the trailing comma to fix it. This is the most common JSON error, especially when hand-editing files.
JSON requires double quotes (") for all strings and property names. Single quotes (') are not valid. {'name':'test'} must be rewritten as {"name":"test"}.
Every opening { must have a matching closing }, and every opening [ must have a matching closing ]. Mismatched or missing brackets cause "Unexpected end of JSON input" or "Unexpected token" errors.
In JavaScript objects, you can write {name:"test"}. In JSON, property names must always be in double quotes: {"name":"test"}.
Standard JSON (RFC 8259) does not support comments. Neither // line comments nor /* block comments */ are allowed. If you need comments in your JSON files, consider using JSONC (JSON with Comments) or JSON5, but be aware that standard JSON parsers will reject them.
JSON.parse expects the entire input to be a single JSON value. Any non-whitespace content after the closing bracket or final value will trigger an error. For example, {"a":1} extra is invalid because of the trailing extra.
JSON.parse implementation, which follows the official JSON specification.Loading...