Comments in JSON, possible or not?

 JSON (JavaScript Object Notation) is an open standard file format and data interchange format that uses human-readable text to store and transmit data objects. 

Douglas Crockford originally specified the JSON format in the early 2000s.

Comments in JSON

Comments were intentionally excluded from JSON. 

In 2012, Douglas Crockford described his design decision thus: 

"I removed comments from JSON because I saw people were using them to hold parsing directives, a practice which would have destroyed interoperability." 

The JSON is data only, and if you include a comment, then it will be data too. You could have a designated data element called "_comment" (or something) that should be ignored by apps that use the JSON data. You would probably be better having the comment in the processes that generate/receives the JSON, as they are supposed to know what the JSON data will be in advance, or at least the structure of it.

For example:


    "_comment": "comment text goes here...",

    "user": {

          "title": "Mr.",

          "firstname": "ravi",

          "lastname": "bhushan",

          "address": {

                 "city": "xyz",




JSON does not support comments. It was also never intended to be used for configuration files where comments would be needed. 

Post a Comment

If you have any questions or concerns, please let me know.

Previous Post Next Post