Skip to content

Instantly share code, notes, and snippets.

@MoOx
Last active May 29, 2025 15:36
How to make comment in JSON file
{
"//field": "These 'double quote' 'double quote' are used as comments, because JSON doesnt' allow comment",
"field": {},
"#another-field": "Another comment",
"another-field": {},
"/*stuff": "Be careful to use them when you have full control of the content :)",
"stuff": [],
"bla": "bla"
}
@xgqfrms
Copy link

xgqfrms commented Apr 14, 2022

@masterewot
Copy link

I found it

@lsloan
Copy link

lsloan commented Oct 17, 2022

Hjson, at https://hjson.github.io/, works better for me than JSON5. YMMV.

Its Python module has been maintained more recently and its documentation shows the syntax of multiline comments as well as #-based comments.

@Alice12s
Copy link

You can create a special key in your JSON Mapquest Directions object to store comments. This key would be ignored by any JSON parsers that don't use it, but it allows you to include notes.

@drivingdirections01
Copy link

This is a trick I've seen somewhere in popular code Mapquest directions but can't remember where, sorry.

@safepestsol
Copy link

You can add a dedicated key to your JSON Safe Pest Sol object for storing comments—JSON parsers that don’t recognize it will simply ignore it, allowing you to include notes without affecting functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment