MyKit.tools

JSON Validator

Validate JSON syntax and find errors with line numbers online for free. Real-time validation as you type with detailed error messages and stats.

How to Validate JSON

Paste your JSON into the editor and the tool instantly checks whether it is valid according to the JSON specification. If the input is valid, you will see a confirmation. If there are errors, the tool highlights the exact line and character position where the problem occurs, along with a human-readable description of what went wrong.

JSON validation is stricter than you might expect if you are used to writing JavaScript objects. Many patterns that work in JavaScript are invalid in JSON. The validator catches all of these issues and tells you exactly what to fix.

Common JSON Syntax Errors

ErrorInvalid ExampleValid Fix
Trailing comma{"a": 1, "b": 2,}{"a": 1, "b": 2}
Single quotes{'name': 'test'}{"name": "test"}
Unquoted keys{name: "test"}{"name": "test"}
Comments{"a": 1} // note{"a": 1}
Undefined/NaN{"val": undefined}{"val": null}
Single valuejust a string"just a string"

JSON vs JavaScript Objects

A JavaScript object and a JSON string look similar but follow different rules. JSON requires all keys to be wrapped in double quotes, all strings to use double quotes (not single quotes or backticks), and does not allow trailing commas, comments, undefined, NaN, Infinity, or functions.

This means you cannot simply copy a JavaScript object literal from your code and use it as JSON. You need to run it through JSON.stringify() first, or manually fix the quoting and remove any unsupported values. The validator helps you spot these differences quickly.

Frequently Asked Questions

Why does my JSON have a trailing comma error?

JSON does not allow a comma after the last element in an object or array. This is one of the most common mistakes because JavaScript does allow trailing commas. Remove the comma after the final item. For example, change [1, 2, 3,] to [1, 2, 3].

Can JSON contain comments?

No. The JSON specification does not support comments of any kind, neither // single-line nor /* multi-line */ block comments. If you need to annotate configuration files, consider using JSONC (JSON with Comments) which some tools support, or move your comments into a separate documentation file.

What is the difference between valid JSON and a valid JavaScript object?

JSON is a strict subset of JavaScript object notation. JavaScript objects allow unquoted keys, single-quoted strings, trailing commas, comments, and special values like undefined or NaN. JSON requires double-quoted keys, double-quoted strings, no trailing commas, no comments, and only null (not undefined) for empty values.

Related Tools