JSON5 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.

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 supported

JSON5 Validation Checklist

Run through this checklist to find common problems.

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.