Skip to content
uencoder

JSONC

JSONC (JSON with Comments) is a JSON variant that allows comments, used mainly for VS Code configuration (tsconfig, settings.json).

Purpose

To allow comments in JSON so configuration files can carry explanations, improving maintainability.

Mechanism

On top of JSON it allows // single-line and /* */ multiline comments; the rest of the syntax is JSON. VS Code and the TypeScript compiler support it. Some implementations also allow trailing commas.

Use cases

  • VS Code settings.json
  • tsconfig.json
  • ESLint configuration
  • IDE configuration files

Examples

  • Input
    {// comment
    "a":1}
    Output
    The object {a:1}

    Comments are allowed

Common errors

A standard JSON parser fails on JSONC
Use a comment-aware parser such as jsonc-parser

Related terms

Related tools

References