How to validate JSON and fix common errors
JSON is intentionally strict. That makes it reliable for APIs, but one small syntax mistake can stop an entire request or configuration file from loading. A validator checks whether text follows the JSON grammar before you use it elsewhere.
Use double quotes for text
Both object keys and string values must use double quotes. The Python-style value {'name': 'Ana'} is not valid JSON. Write {"name": "Ana"} instead. This is the most frequent mistake when moving examples between JavaScript, Python and JSON files.
Remove trailing commas
JSON does not allow a comma after the final item in an object or array. Remove the comma after the final value before parsing. JSON also does not accept comments, even when the surrounding programming language does.
Use JSON literals
JSON recognizes true, false and null, all in lowercase. Python's True, False and None are not valid JSON. These differences are small but matter whenever text crosses a language boundary.
Validate before debugging the application
When an API returns a parsing error, validate the exact response or request body first. Then check expected field names and data types. A syntactically valid document can still fail an API schema if a field expected to be a number is sent as text.
Use the JSON to Python converter to inspect a valid document, then read our JSON to Python guide for the next step.