You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
jsonc: Setting to allow trailing commas in jsonc #237258
Formatting jsonc with prettier adds trailing commas which vs code then flags as being invalid: prettier/prettier#15553
The proposed solution there is to define a jsonschema and use a vscode-specific extension to json-schema property to allow it. I'm already using an externally defined jsonschema that I can't edit, so this isn't a solution for me.
I'd like to request this be a standard vs code setting (in addition to the existing jsonschema setting). All my tooling supports trailing commas so I do not need to customize the behavior for specific files. I'd be happy for this to be off by default.
FWIW, even if I could disable trailing commas I wouldn't want to. They make editing easier and more robust to reordering fields, adding and deleting the final field, etc.
If you already have an existing jsonschema setting, just add another one that matches your file. Matching schemas are all combined.
You can even do it for all jsonc files:
Philipp A. (@flying-sheep) Because if getSchemaForResource sees a $schema property in your JSON file, it returns immediately and set the value of $schema as the schema of that JSON file.
The alternative that works is to remove the $schema property from your JSON file, and set the schema only in .vscode/settings.json. This way the schema of a JSON file will be merged for all matching fileMatch.
I faced the same problem as yours, digging into the source code under frustration, then found the solution I shared, tried it and it really works! Which means the behavior matches exactly what the source code says it does.
So I think maybe you are facing more than this issue, and I suggest you dig deeper into it.
I'm very confident this solution works. Some of my colleagues also tried it and it works as well.
I think I wasn’t clear: I meant that “remove the $schema property from [my] JSON file” isn’t possible, so I can’t use your workaround and need a real solution.
Activity
aeschli commentedon Jan 7, 2025
If you already have an existing
jsonschemasetting, just add another one that matches your file. Matching schemas are all combined.You can even do it for all jsonc files:
andrewbaxter commentedon Jan 7, 2025
Ah thanks, works for me!
flying-sheep commentedon May 14, 2025
It doesn’t for me.
biome.jsonc:{ "$schema": "https://biomejs.dev/schemas/1.9.4/schema.json", }user
settings.json:{ ..., "json.schemas": [{ "fileMatch": ["*.jsonc"], "schema": { "allowTrailingCommas": true, }, }], }shian15810 commentedon Mar 16, 2026
Philipp A. (@flying-sheep) Because if
getSchemaForResourcesees a$schemaproperty in your JSON file, it returns immediately and set the value of$schemaas the schema of that JSON file.The alternative that works is to remove the
$schemaproperty from your JSON file, and set the schema only in.vscode/settings.json. This way the schema of a JSON file will be merged for all matchingfileMatch.{ "json.schemas": [ { "fileMatch": [ "**/*.jsonc", ], "schema": { "allowComments": true, "allowTrailingCommas": true, }, }, { "fileMatch": [ "**/biome.jsonc", ], "url": "https://biomejs.dev/schemas/latest/schema.json", }, ], }Reference: https://github.com/microsoft/vscode-json-languageservice/blob/a78b2ff4f8903edddb51788698bdf149f64f1650/src/services/jsonSchemaService.ts#L697-L713
flying-sheep commentedon Mar 16, 2026
That workaround doesn’t work for me and I’m sure in many other cases.
So if there’s no way to make VS Code shut up without touching my data, please reopen this issue Martin Aeschlimann (@aeschli)
shian15810 commentedon Mar 16, 2026
Philipp A. (@flying-sheep) Based on the source code, it should and must work.
I faced the same problem as yours, digging into the source code under frustration, then found the solution I shared, tried it and it really works! Which means the behavior matches exactly what the source code says it does.
So I think maybe you are facing more than this issue, and I suggest you dig deeper into it.
I'm very confident this solution works. Some of my colleagues also tried it and it works as well.
flying-sheep commentedon Mar 16, 2026
I think I wasn’t clear: I meant that “remove the $schema property from [my] JSON file” isn’t possible, so I can’t use your workaround and need a real solution.
shian15810 commentedon Mar 16, 2026
Philipp A. (@flying-sheep) Could you explain more on the why?
Note that both
allowCommentsandallowTrailingCommasare vscode-only semantics, so adding them to.vscode/settings.jsonis appropriate.flying-sheep commentedon Mar 17, 2026
Biome needs the
$schemain its JSON file. And if I understood you correctly, amending the schema in settings.json doesn’t work then.I’m asking to make it work or allow some other way to merge the VS Code only property into a schema.
RedCMD commentedon Mar 17, 2026
modify the schema directly?
flying-sheep commentedon Mar 17, 2026
No, the schema that is referenced with by URL stays static.
Please stop recommending workarounds and open the discussion for actual solutions.