DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober 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 PC×
Skip to content
World desk9 min

How to Fix JSON Parsing Errors Caused by Comments or Trailing Commas

Strict JSON rejects comments and commas before closing braces or brackets. This guide shows safe repairs and explains the trade-offs between JSON, JSONC, and JSON5.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Standard JSON has no comment syntax and does not permit a comma before a closing } or ]. Delete comments and final-item commas when the data must be strict JSON. If annotations or trailing commas are intentional, use a parser and consumer that explicitly support JSONC or JSON5 instead.

What strict JSON actually allows

JSON is a data-interchange format with its own grammar; it is not the same thing as a JavaScript object literal. RFC 8259 defines an object as a set of members with quoted string names and comma-separated values. An array is a comma-separated sequence of values. In both cases, commas separate items. A comma after the final item, immediately before } or ], is outside that grammar.

As an Amazon Associate I earn from qualifying purchases.

The grammar also has no token for either // line comments or /* ... */ block comments. An editor may color those characters as comments because it is treating the file as JavaScript, JSONC, or another relaxed format, but a strict JSON parser still sees unexpected characters. The same applies when a file begins as a JavaScript object literal and is later sent to an API that accepts only JSON.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Object member names: use double-quoted strings, such as "name".
  • Separators: put commas between members or array values.
  • Final item: do not put a comma between the final value and the closing delimiter.
  • Comments: remove them from strict JSON; they are not ignored automatically.

These rules explain why a parser can reject text that looks perfectly familiar in source code. Familiarity with JavaScript punctuation does not make that punctuation valid JSON.

#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.

How to interpret the location reported by the parser

Start with the line, character, or byte offset reported by the parser, then inspect the surrounding structure rather than only the highlighted character. A parser often reports the next token it cannot accept. For a trailing comma, that token may be the closing } or ]; the comma that caused the problem appears immediately before it. This is a useful debugging heuristic, not a guarantee shared by every implementation.

  1. Look backward from the reported position to the previous non-whitespace character.
  2. If that character is a comma and the next structural character is } or ], remove the comma.
  3. If the reported position is at /, inspect whether the text begins // or /*. Those are comments, not strict JSON.
  4. Check the surrounding object or array for a missing comma between two actual items. Removing every comma would create a different error.
  5. After each edit, parse the complete document with the same parser used by the receiving application.

Do not assume that the first reported error is the only one. A file can contain a comment, a trailing comma, and a separate missing quote; parsers commonly stop at the first construct they cannot process.

Repair the text when strict JSON is required

Strict JSON is the compatibility-first choice for API requests, exchanged data, and files read by an unknown consumer. Make a copy of the original before editing, then work through the structure deliberately.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Identify the real consumer. Determine which service, library, command, or application reads the text. Its parser—not the editor’s syntax highlighting—defines what is accepted.
  2. Remove comments manually or with a format-aware parser. Delete complete // lines or /* ... */ blocks, but preserve any text inside quoted strings.
  3. Remove final-item commas. In every object, delete the comma immediately before }; in every array, delete the comma immediately before ].
  4. Keep separators between items. If one member or value is followed by another, the comma between them remains.
  5. Check names and strings. Object names must be double-quoted, and string contents must use valid JSON escaping.
  6. Validate with the production parser. A generic validator can find syntax errors, but the receiving application may impose additional limits or a different accepted format.

Object with a comment and a trailing comma

This input contains two independent strict-JSON violations:

{
  "name": "Ada", // comment
  "active": true,
}

The strict form removes the comment and the comma after the final member:

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.
{
  "name": "Ada",
  "active": true
}

The comma after "name": "Ada" stays because another member follows it. Only the comma directly before the closing brace is removed.

Array with a trailing comma

The same rule applies to arrays:

{
  "roles": [
    "admin",
    "editor",
  ]
}

In strict JSON, the final array value has no following comma:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
{
  "roles": [
    "admin",
    "editor"
  ]
}

Nested structures need separate checks

Inspect each closing delimiter at its own level. An object can be valid while an array nested inside it has a trailing comma, or vice versa. For example, the comma after the final object in an array is invalid even though the object itself may contain several correctly separated members. Work from the innermost closing bracket outward and verify every object and array.

Why a regular expression is a risky universal fix

Do not delete every occurrence of //, /*, or a comma followed by optional whitespace and a closing delimiter with a blind regular expression. Comment-like characters can occur inside legitimate strings, such as a URL or a message:

{
  "url": "https://example.test/a//b",
  "message": "Use /* carefully */ in documentation"
}

A text substitution that does not understand quoted strings can corrupt those values. Prefer editing the known offending lines, or parse the intended extended format with a parser that understands strings, comments, and nesting.

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

How comments create a misleading “JSON” file

Comments are common in source code and configuration files, so it is easy to assume they are universally harmless. They are not part of the JSON grammar. A strict parser cannot treat a comment as whitespace unless the implementation deliberately adds that extension.

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

There is also a transport issue. A file may be authored in an editor that supports comments, then uploaded with a media type or API contract that promises JSON. The receiving side is entitled to apply strict JSON rules and reject the payload. Renaming the file or changing syntax highlighting does not convert its contents.

If the comments explain values for people maintaining a configuration, decide whether those annotations belong in a separate documentation file, in a schema, or in an explicitly supported extended format. Keeping comments is a format decision, not merely a cosmetic preference.

JSONC: comments for a deliberate configuration format

JSONC is a JSON-derived format that adds JavaScript-style comments. Its specification documents both line and block comments and describes trailing commas as optional behavior. The reference jsonc-parser setting allowTrailingComma is false by default, so a JSONC parser configured with its defaults can still reject a trailing comma. The specification states: “The allowTrailingComma option is set to false by default, so any trailing comma will result in a parsing error.” See the JSONC specification.

That default matters when a file has comments but still fails at a final comma. Enabling comments does not automatically enable every other extension. Check the actual parser options and the application that invokes it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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.

Use the format and extension consistently

JSONC documentation recommends the .jsonc extension for JSONC files. Treat that extension as a clear signal to tools and maintainers, not as a conversion mechanism. A consumer must still implement JSONC parsing; a filename alone cannot make a strict parser accept comments.

The same documentation cautions against transmitting JSONC as application/json. A JSON-only consumer may reject it or interpret the contract incorrectly. If a service expects standard JSON, remove comments before sending the request. If it expects JSONC, follow that service’s documented media type and parser requirements.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

JSON5: comments, trailing commas, and additional relaxed syntax

JSON5 is a distinct format rather than a switch that makes every JSON parser more permissive. Its specification includes comments and trailing commas, along with other syntax extensions. Those conveniences can make hand-maintained configuration easier, but they also increase the distance from strict JSON.

A JSON5 file must be read by a JSON5-aware parser, and every downstream consumer must agree on that choice. A component that accepts JSON5 may parse a file successfully while an API, build step, or deployment tool later rejects the same text as invalid JSON. Confirm support in each stage before changing an existing interchange format.

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.

When converting JSON5 back to strict JSON, use a parser or a careful conversion step rather than deleting punctuation with a regular expression. JSON5’s additional syntax means there may be more than comments and trailing commas to normalize.

Choose the format based on the receiving system

Need Format Comments Trailing commas What to verify
Data sent to APIs, exchanged across systems, or read by an unknown parser Strict JSON Not allowed Not allowed Validate with the same parser or production consumer.
Human-annotated configuration handled by a JSONC implementation JSONC Supported Optional in the format; the documented jsonc-parser default is disabled Confirm JSONC support, parser options, file extension, and transport contract.
Configuration that intentionally uses comments, trailing commas, and other relaxed syntax JSON5 Supported Supported Confirm that every reader and downstream consumer accepts JSON5.

There is no safe “enable comments everywhere” setting. The appropriate fix depends on whether you control the parser and all consumers. If the data crosses an organizational or system boundary, strict JSON avoids an extension mismatch. If it stays inside a controlled configuration toolchain, JSONC or JSON5 can be appropriate when explicitly documented.

Check the entire toolchain, not just one parser

A successful parse in an editor proves only that the editor’s parser accepts the text. Trace the document through every stage:

  1. Authoring: Which syntax does the editor or generator produce?
  2. File identity: Does the extension communicate strict JSON, JSONC, or JSON5 accurately?
  3. Transport: What media type or protocol field describes the payload?
  4. Parsing: Which library reads it, and are options such as trailing-comma support enabled?
  5. Validation: Does a schema checker or build step apply stricter rules than the parser?
  6. Consumption: Does the next service receive the parsed data, or does it read the original text again?

This sequence explains many “works locally, fails in production” cases. A local editor may accept JSONC while the deployment service expects strict JSON. Conversely, a JSONC parser may be configured to allow comments but retain its default prohibition on trailing commas.

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

Common symptoms and targeted fixes

The error points at a closing brace or bracket

Inspect the character immediately before that delimiter. If it is a comma, remove it and parse again. If the preceding value is followed by no comma but another member begins, add the missing separator instead. The delimiter is often where the parser notices the problem, not where the mistake was typed.

The file contains comments and the parser stops at a slash

Confirm whether the consumer is strict JSON. If it is, remove the comments while preserving string contents. If comments are a requirement, migrate the file and consumer together to JSONC or JSON5 rather than assuming the existing parser has an undocumented switch.

Removing the comma still leaves an error

Search for additional trailing commas in nested objects and arrays. Then inspect quotes, escaping, brackets, and braces. A document can contain several syntax errors, and a parser normally reports only the first one it encounters.

An editor accepts the file but an API rejects it

Compare the editor’s format mode with the API contract. Send strict JSON unless the API explicitly documents JSONC or JSON5. Do not send a commented file under application/json merely because the editor can open it.

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

The data was copied from JavaScript

Convert object-literal syntax deliberately. Quote every member name, remove comments, remove final-item commas, and check for other JavaScript-only constructs. JSON values are limited to strings, numbers, objects, arrays, true, false, and null; familiar source-code expressions are not automatically JSON values.

A safe validation workflow

  1. Save the original text so you can compare or restore it.
  2. Record the exact consumer and format it claims to accept.
  3. Fix the first reported location, beginning with a possible comment or comma before a closing delimiter.
  4. Review the complete nesting for additional final-item commas.
  5. Check that every object member name and string uses valid JSON quoting and escaping.
  6. Run the document through the production parser or an equivalent validator configured for the same format.
  7. If you selected JSONC or JSON5, test the handoff to the next component, not only the authoring tool.
  8. Keep the file extension, media type, parser configuration, and documentation aligned.

Practical decision checklist

  • Choose strict JSON when compatibility with unknown or external consumers matters.
  • Choose JSONC when comments are needed in a controlled configuration workflow and every reader supports JSONC.
  • Choose JSON5 when you intentionally need its broader relaxed syntax and can guarantee JSON5 support end to end.
  • Never assume that accepting comments means accepting trailing commas; verify the parser option.
  • Never treat a filename change as a syntax conversion.
  • Never remove comment-like text with a blind regular expression when strings may contain those characters.

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.

Leave a Reply

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

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.

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
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

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.