How to validate a JSON file and understand the first error
A syntax validator answers whether a document follows strict JSON grammar. It is useful when a parser rejects a payload and you need the location and likely cause of the first problem.
When should you use it?
- Diagnose a failing API response or configuration file.
- Check a hand-edited document before committing it.
- Spot duplicate names that may be interpreted differently by downstream parsers.
Example: a trailing comma
The comma after the final property makes this invalid JSON. Remove it, then validate again.
{"name":"Alex",}Trailing comma before }Read the error in its surrounding context
A parser reports where it can no longer continue. If a comma is missing between two properties, that location may be the next property name rather than the preceding value. Look at the marked token and the text immediately before it. Fix one error, run the check again, and work forward through the document.
A response beginning with an HTML tag often means an API returned an error page. Removing the tag will not recover the expected response; check the HTTP status and response body in the application that made the request.
Separate grammar from application rules
A quoted number such as "42" is valid JSON, as is an empty object. Your application may require an integer id and a nonempty name. Those requirements belong in a schema or application validator. Duplicate property names deserve attention too: the syntax can be accepted, but different consumers may retain different values. This validator warns about them so you can resolve the ambiguity.
Find the first problem. Understand the fix.
Validation identifies the point where a parser can no longer continue. Review that location and the preceding token; an earlier missing comma can cause several later errors.
Paste the failing document
Your source remains unchanged during validation.
Inspect the diagnostic
Jump to the line, column, and zero-based character position.
Correct and recheck
Use the suggestion as guidance, then validate your edit.
Why does a JavaScript object literal fail strict JSON validation?
JavaScript accepts syntax that JSON does not, including unquoted property names and single-quoted strings. JSON requires double-quoted names and string values, lowercase true and false, and no trailing comma. Paste the actual serialized text rather than a JavaScript expression to find the first invalid token.
JavaScript: the parser rejects a trailing comma
javascriptJSON.parse('{"ready":true,}'); // SyntaxError
JSON.parse('{"ready":true}'); // { ready: true }The validator highlights the failure location in the source. Correct the comma and run it again; an earlier error can hide a later one.
Does valid JSON mean my API request is valid?
No. Syntax validation checks grammar only. A request can parse successfully yet omit required fields or use a string where an integer is expected. Use JSON Schema Validator for those contract checks.
What should you check before using the result?
Syntax validity says nothing about required application fields or data types. Use the JSON Schema Validator when a payload must satisfy a contract. A diagnostic may point after the actual missing token.
Syntax errors versus warnings
Missing commas, single-quoted names, incomplete strings, comments, and trailing commas are syntax errors. Duplicate property names are reported separately as warnings: the syntax is valid, but other parsers may discard values.
What this validator checks
A document must contain one strict JSON value. Objects, arrays, strings, numbers, booleans, and null are accepted at the root. Schema validation is a different task: this tool does not check required fields or business rules.
Technical reference: JSON syntax and interoperability · RFC 8259