Exploring how JSON with Comments (JSONC) addresses the limitations of standard JSON for human-editable files.
HM Journal
•
3 days ago
•
How-to Geek
The world of software development often grapples with the subtle nuances of data interchange and configuration formats. For years, JSON (JavaScript Object Notation) has been the undisputed champion, celebrated for its simplicity and universality. Yet, its inherent strictness, while a boon for machine parsing, can be a bane for human readability and maintainability. This is where JSONC, or JSON with Comments, enters the picture, offering a compelling, though unofficial, alternative. It's not about replacing JSON entirely, but rather about enhancing it for specific, developer-centric scenarios, a trend increasingly apparent in today's tooling and AI-driven workflows.
At its core, JSON is a language-independent data format derived from JavaScript object literal syntax. Standardized by ECMA-404, it was designed for lightweight data interchange, emphasizing a minimalist structure that's easy for machines to parse and generate. This strictness means no comments, no trailing commas, and certainly no unquoted keys. Everything must adhere to a precise specification, ensuring interoperability across diverse programming languages and systems.
tsconfig.json or package.json file without any explanatory notes can be, well, a real headache.//) and multi-line (/* ... */) comments. Some implementations also gracefully handle trailing commas in arrays and objects, and even occasionally permit unquoted keys, though these are less universally adopted features than comments themselves.The origin story of JSONC is deeply intertwined with developer tooling, particularly Microsoft's Visual Studio Code. VS Code popularized JSONC, making it a default for many of its internal configuration files, which totally makes sense. Since around 2017, and especially after version 1.50 in 2020, its "JSONC mode" has allowed developers to add explanatory notes directly within their configuration files. This capability has been a game-changer for maintainability, especially in larger projects. Think about how much easier it is to onboard a new developer when config files explain themselves.
The practical advantages of JSONC over plain JSON become strikingly clear when you consider its primary use case: human-editable configuration files. In a typical development workflow, configuration files are constantly being updated, merged, and reviewed.
While JSONC offers undeniable benefits for developer experience, it's important to acknowledge potential trade-offs. Because JSONC files contain extra characters (the comments themselves), they are technically larger than their pure JSON counterparts. More critically, parsing JSONC is generally 5-15% slower than parsing strict JSON due to the additional logic required to strip out comments and handle other relaxed syntax rules. For high-throughput data interchange, where every millisecond counts, this parsing overhead can be a factor. This is why ECMA International, the stewards of the JSON standard, still emphasizes JSON's intentional minimalism and warns of potential interoperability issues with extensions like JSONC in strict environments.
Despite this, JSONC's adoption has seen a significant surge, growing 40% in open-source repositories over the past year. Tools like ESLint v9.0, released in October 2025, now support JSONC for configuration files without needing extra dependencies. Node.js v22 also introduced experimental support for JSONC, recognizing its value for "config-heavy apps." This growth is partly fueled by a broader trend towards more flexible "JSON-like" formats, particularly driven by the explosion of AI applications. For instance, in AI prompts for Large Language Models (LLMs), JSONC's ability to embed inline explanations can reduce token usage, leading to reported 30-50% efficiency gains in certain AI workflows. It allows for annotated data, which can be immensely helpful without bloating the actual data payload for the LLM.
The question "Is JSONC better than JSON?" is fundamentally flawed, as it implies a direct competition for all use cases. The truth is, they serve different, albeit related, purposes. JSON remains the gold standard for data interchange, especially in APIs, where machine readability and strict adherence to a universal standard are paramount. Its speed and universality ensure robust, error-free communication across systems. Douglas Crockford, JSON's creator, has always maintained that the lack of comments was a deliberate design choice for simplicity, and he sees value in JSONC for contexts beyond pure data transfer.
JSONC, however, clearly shines in scenarios where humans are the primary authors and maintainers of structured data, like configuration files, settings, and manifest declarations. It bridges the gap between machine efficiency and human usability. It's not a replacement, but a pragmatic superset that significantly enhances the developer experience, reducing frustration and improving clarity. For any project involving configuration that will be edited by a development team, embracing JSONC can lead to more maintainable codebases and a smoother collaborative environment. The choice, ultimately, hinges on whether the file's primary audience is a machine or a human developer.