Why doesn't JSON support comments?
Written by Stefan Judis
- Published at
- Updated at
- Reading time
- 1min
Did you ever curse the JSON data format for not allowing comments and wondered what the heck? Yeah, same here.
Surprisingly, JSON, in its initial spec, did allow comments, but comment support was removed for three reasons:
- People put parsing instructions into comments breaking portability across platforms and languages.
- Comments introduced complexity that might not be needed for a data format.
- The JSON creators wanted it to be compatible with early YAML versions.
It's a bummer because JSON outgrew its serial data use case, and it's widespread to have JSON config files these days. :/
Pawel Grzybek pointed out that the lack of comments and other features led to the JSON5 spec, which aimed to be a JSON extension suitable for config files and was adopted by VS Code and many other software products today.
If you want to learn more, here's why comments were removed on YouTube.
If you enjoyed this article...
Join 5.5k readers and learn something new every week with Web Weekly.
Reply to this post and share your thoughts via good old email.