Search code examples
jsonvisual-studio-code

How to add comments to a settings.json file in VSCode?


My VSCode settings.json file is large and I often forget what different settings do and why I have them set a particular way. Hovering the keys in the opened files shows what they affect, but hovering is tedious, slow, and may lack information that helps me understand what the setting does and why I have set it to a particular value.

Is there any way to add something like in-line comments to the file, such as the # does X text in the below settings.json example? I know that JSON files cannot have comments but there are JSON formats that allow comments.

{
    "security.workspace.trust.untrustedFiles": "open",  # does X
    "editor.guides.bracketPairs": "active",
    "r.bracketedPaste": true
}

Solution

  • settings.json is a JSONC (JSON with Comments) file. While standard JSON does not support comments, JSONC supports including comments (both in-line and stand-alone) with //.

    Thanks to jonrsharpe for the insight.