October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk8 min

How to Allow Comments and Trailing Commas in VS Code JSON Files

Switch VS Code JSON files to JSON with Comments (jsonc) to use // comments, /* block comments */, and trailing commas—then configure files.associations for a persistent setup.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Visual Studio Code’s JSON with Comments language mode, identified as jsonc. It accepts JavaScript-style // line comments, /* ... */ block comments, and trailing commas. For a single open file, change the language mode from the status bar; for a repeatable setup, associate a filename or extension with jsonc through files.associations.

What changes when you use JSON with Comments

Standard JSON is deliberately strict: it does not define comments, and the final property in an object or item in an array cannot be followed by a comma. Visual Studio Code separates that strict mode from a second language mode called JSON with Comments. Its language identifier is jsonc.

As an Amazon Associate I earn from qualifying purchases.

In JSONC mode, the editor accepts two comment forms:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • // starts a comment that continues to the end of the line.
  • /* starts a block comment that ends at the next */, and the block can span multiple lines.

The mode also accepts trailing commas. Microsoft’s VS Code JSON documentation cautions: “The mode also accepts trailing commas, but they are discouraged and the editor will display a warning.” That warning is an editor warning, not a sign that the language mode failed.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

Changing the mode affects how VS Code parses, highlights and validates the open document. It does not rewrite the file, convert it for another application, or make an external JSON parser understand JSONC.

Change one open file to JSON with Comments

This is the quickest option when you are editing a file occasionally or do not want to change how similarly named files open later.

  1. Open the JSON file in VS Code.
  2. Look at the language-mode indicator on the right side of the editor status bar. It will normally say JSON for an ordinary JSON document.
  3. Select the indicator to open the language-mode picker.
  4. Choose JSON with Comments.

The document should now be treated as jsonc. You can add a line comment, a block comment or a trailing comma and the editor will parse the syntax accordingly. The selection applies to that open document; it is the appropriate choice for a one-off edit.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If the status bar says something unexpected

The status-bar label is the mode VS Code is using for the current editor, not necessarily the file extension on disk. If the file was previously assigned another language, select the label again and choose JSON with Comments. Check the label after switching so you know which mode is active before diagnosing a syntax warning.

Make JSONC the default for particular files

Use files.associations when a filename or pattern should consistently open as JSONC. This is more persistent than selecting a mode manually each time.

  1. Open the Command Palette with Ctrl+Shift+P on Windows or Linux, or Cmd+Shift+P on macOS.
  2. Run Preferences: Open User Settings (JSON) to apply the association to your user profile, or run Preferences: Open Workspace Settings (JSON) to apply it only to the current project.
  3. Add a files.associations object, or add a new entry to the existing object.
  4. Save the settings file, then reopen the target file if its language mode does not update immediately.

For example, this maps every file ending in .myconfig to JSONC:

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.
{
  "files.associations": {
    "*.myconfig": "jsonc"
  }
}

Replace *.myconfig with the pattern that matches your files. A literal filename can also be used when only one named file needs the association. The value must be jsonc, which is VS Code’s language identifier for JSON with Comments.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

User settings versus workspace settings

Choose the scope based on who should receive the behavior:

Scope Where it applies Best fit What to know
User Across your VS Code projects A personal convention used in many repositories The association is stored in your user settings.json.
Workspace Only the current project A repository with its own configuration-file extension or convention The setting is stored with workspace configuration in the project’s .vscode folder.
Open-file selection The current editor document A temporary or one-time change It does not create a persistent filename association.

The exact filesystem location of a user settings file varies by operating system and whether you are working in a local, remote or multi-root workspace. Using the Command Palette commands is more reliable than navigating to a guessed path.

Comment syntax that JSONC accepts

Single-line comments

Place // before an explanatory note:

{
  "port": 8080,
  // The service listens on the local development port.
  "host": "127.0.0.1"
}

A line comment runs to the line ending. Keep it outside a quoted string; // inside a string is ordinary string content, not a comment marker.

Block comments

Use /* ... */ for a note that spans lines or sits between properties:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
{
  "features": {
    /* Enabled for the staging workspace only. */
    "preview": true
  }
}

The closing */ is required. An unclosed block comment leaves the document invalid even in JSONC mode.

Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

Comments do not become data

Comments are editor syntax, not object properties. A tool that reads the file must either understand JSONC or receive a cleaned, strict-JSON version. Do not assume that a comment survives parsing, serialization or a build step.

How trailing commas behave

A trailing comma is the comma after the final member of an object or the final value of an array:

{
  "name": "demo",
  "enabled": true,
}

JSONC mode accepts this form and VS Code displays a warning because trailing commas are discouraged. The warning is intentional: many tools consume strict JSON and will reject the same text. Removing the final comma produces syntax accepted by strict JSON as well as JSONC:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
{
  "name": "demo",
  "enabled": true
}

Trailing commas can be convenient while editing a growing list because adding another property does not require changing the preceding line. They are not a portability guarantee. If a file is exchanged with another program, generated for an API request or validated by a strict JSON parser, omit them unless that consumer explicitly documents JSONC support.

Which method should you use?

The two practical methods solve different problems:

Method Scope Persistence Settings access required? Use it when
Status-bar language picker One open file Temporary for that document No settings-file edit You need to inspect or edit one file without changing project behavior.
files.associations Every matching filename or pattern Persistent Yes; user or workspace settings A custom extension or named file should always behave as JSONC.

Neither method changes the bytes in the file automatically. They tell VS Code which language service to use. If another contributor opens the same file without the association, that person may see ordinary JSON mode unless the project’s workspace settings are shared.

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.

VS Code files that already use JSONC

Several built-in VS Code configuration files are examples of JSONC in practice. settings.json, tasks.json and launch.json use JSON with Comments, which lets you annotate settings and leave trailing commas while editing. Their behavior is part of VS Code’s own configuration support; it is not evidence that every third-party configuration reader accepts the same syntax.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Settings-file examples

Associating a custom extension

A complete workspace settings file might look like this:

{
  "files.associations": {
    "*.service-config": "jsonc"
  }
}

After saving, open a file such as development.service-config. The status bar should identify it as JSON with Comments. If it still shows another mode, close and reopen the file, then inspect whether a more specific language selection was applied to that editor.

Associating a filename

For a single conventional filename, use a filename pattern:

{
  "files.associations": {
    "project.config": "jsonc"
  }
}

This avoids assigning JSONC to unrelated files that happen to share a broad extension.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Adding an association without deleting existing settings

If files.associations already exists, add a comma after the previous entry and insert the new pattern inside the same object. Do not create a second property with the same key and expect both objects to merge predictably. Preserve the surrounding settings and let VS Code report any genuine JSONC syntax error in the settings file.

Troubleshooting

The editor still underlines comments

  • Check the status-bar language label. It must say JSON with Comments, not JSON.
  • If the file has a custom extension, verify that the pattern in files.associations matches the complete filename.
  • Reopen the file after saving the settings association.
  • Look for an unclosed block comment or a comment marker placed inside an incorrectly quoted string.

A trailing comma still shows a warning

That is expected in JSONC. VS Code accepts the comma but warns that it is discouraged. Remove the comma when you need warning-free JSONC or maximum compatibility with strict JSON consumers.

The association works in one project but not another

Determine where you saved it. A workspace association applies only to that project, while a user association applies across your projects. In a multi-root workspace, make sure you opened the settings scope intended for the relevant workspace rather than another folder.

The external tool rejects the file

VS Code’s acceptance is not a promise from the application that consumes the file. Read that tool’s parser documentation. If it requires standard JSON, remove comments and trailing commas, or generate strict JSON as a separate build artifact. Do not solve a runtime parser error merely by changing the editor’s colorization mode.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The settings file itself is broken

Open the Command Palette and use the appropriate Preferences: Open User Settings (JSON) or Preferences: Open Workspace Settings (JSON) command. VS Code will show diagnostics in the settings editor. Check braces, quotes and commas around the association, then save and reopen the target file.

Sharing JSONC safely

Before committing a JSONC file or handing it to another system, identify its consumer:

  • VS Code configuration: JSONC is the expected editing mode for the built-in configuration files listed above.
  • A tool that documents JSONC support: Comments and trailing commas may be acceptable, but follow that tool’s exact parser rules.
  • A strict JSON API, schema validator or generic parser: Use standard JSON syntax, with no comments and no trailing commas.
  • A file used by multiple tools: Keep the source in the format all consumers support, or add a deliberate conversion step that strips comments and trailing commas before distribution.

Changing the language mode is therefore an editor decision, not a file-format migration. If portability matters, strict JSON remains the safer interchange format.

A quick checklist

  1. Open the file and inspect the status-bar language indicator.
  2. Choose JSON with Comments when you need //, /* ... */ or trailing-comma syntax.
  3. Use files.associations with the value jsonc when the choice should persist for matching files.
  4. Put a persistent association in user settings for your own projects, or workspace settings when the project should define the behavior.
  5. Treat VS Code’s trailing-comma warning as a compatibility reminder, not an error in JSONC mode.
  6. Confirm that the external parser or runtime accepts JSONC before sharing or executing the file.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.