Troubleshooting
Common problems and solutions when working with JSON5.
Quick Fix: Most JSON5 errors are parse errors from invalid syntax. Check for unclosed strings, missing commas, or reserved words used as unquoted keys.
Common Issues
Browse by problem type to find solutions.
Parse Errors
Fix syntax errors and invalid JSON5
Most CommonTrailing Commas
Issues with commas after the last item
Encoding Issues
UTF-8, BOM, and character problems
TypeScript Errors
Type issues with JSON5 parsing
Common Mistakes
Frequent errors and how to avoid them
Error Reference
Complete list of error messages
Quick Fixes
Try these common solutions first.
"Unexpected token" Error
Usually caused by a missing comma, unclosed string, or invalid character.
// Wrong - missing comma { a: 1 b: 2 } // Correct { a: 1, b: 2 }"Invalid identifier" Error
Unquoted keys must be valid JavaScript identifiers. Quote keys with special characters.
// Wrong - contains hyphen { my-key: 'value' } // Correct - quoted { 'my-key': 'value' }"Reserved word" Error
Reserved JavaScript words can't be used as unquoted keys. Quote them instead.
// Wrong - 'class' is reserved { class: 'container' } // Correct - quoted { 'class': 'container' }Comments Not Working
Make sure you're using a JSON5 parser, not a regular JSON parser.
// Wrong - using JSON.parse() JSON.parse(text) // Comments will cause errors // Correct - using JSON5.parse() JSON5.parse(text) // Comments are supportedJSON5 Validation Checklist
Run through this checklist to find common problems.
Online Validation
Use online tools to quickly validate your JSON5.
Getting Help
If you're still stuck, here are ways to get help.
GitHub Issues
Report bugs or ask questions on the json5 GitHub repository.
Stack Overflow
Search or ask questions with the json5 tag on Stack Overflow.
Contact Us
Have a question about this documentation? Contact us.
Still Having Issues?
Check our detailed parse errors guide or explore the complete error reference.