How Do I Check If My JSON Is Valid?
Paste your JSON into a validator to check if it is valid. Common errors: trailing commas, single quotes, unquoted keys. Valid JSON requires double-quoted strings and keys, no trailing commas, no comments, and proper nesting of brackets and braces.
Most Common JSON Errors
| Error | Invalid | Valid |
|---|---|---|
| Trailing comma | {"a": 1,} | {"a": 1} |
| Single quotes | {'a': 'b'} | {"a": "b"} |
| Unquoted keys | {a: 1} | {"a": 1} |
| Comments | {"a": 1 // comment} | {"a": 1} |
| Missing comma | {"a": 1 "b": 2} | {"a": 1, "b": 2} |
Validate in Code
JavaScript
function isValidJSON(str) {
try { JSON.parse(str); return true; }
catch (e) { return false; }
}
isValidJSON('{"a": 1}'); // true
isValidJSON('{a: 1}'); // false
Command Line
# Python
echo '{"a": 1}' | python -m json.tool
# jq
echo '{"a": 1}' | jq '.'
Try It Yourself
Use our JSON Validator to check any JSON instantly, or our JSON Formatter to pretty-print it.
Frequently Asked Questions
How do I validate JSON in the command line?
Use echo '{"a":1}' | python -m json.tool or echo '{"a":1}' | jq '.'. Both print formatted output if valid, or an error if invalid.
Does JSON support comments?
No. Standard JSON (RFC 8259) does not support comments. If you need comments, consider JSONC (JSON with Comments) used by VS Code, or JSON5.