Format JSONC (JSON with Comments)
online, free & instant
Paste your JSONC — settings.json, tsconfig.json, or any JSON with comments — and get clean, valid JSON. Strips comments, fixes trailing commas, and formats beautifully. All in your browser.
Open JSONC FormatterFrom JSONC to valid JSON in seconds
No account. No upload. No nonsense.
100% Private
Your config files never leave your device. There is no server receiving your data.
Instant Output
Comment stripping and formatting happen as you type. No backend round-trips.
7 Repair Transforms
Beyond comments — fixes unquoted keys, single quotes, Python literals, undefined, and more.
Related JSON tools
Common questions answered
What is JSONC and how is it different from JSON?
JSONC (JSON with Comments) is a superset of JSON that allows single-line (//) and multi-line (/* */) comments, as well as trailing commas. It is widely used in VS Code settings, tsconfig.json, and other configuration files. Standard JSON parsers reject comments, so JSONC must be stripped before parsing.
Does this tool strip comments from JSONC?
Yes. The Repair tab automatically removes both single-line and multi-line comments, strips trailing commas, and produces valid standard JSON that any parser can handle.
Can I use this for VS Code settings.json or tsconfig.json?
Absolutely. Paste your VS Code settings.json or tsconfig.json content and the tool will format it, strip comments if needed, and produce clean JSON. This is useful when you need to share or process config files with standard JSON tools.
What comment types are supported?
The tool handles both single-line comments (// comment) and multi-line block comments (/* comment */). It also fixes trailing commas that are common in JSONC files.
Is my data sent to a server?
No. All formatting and comment stripping runs entirely in your browser using JavaScript. Your JSONC content is never uploaded or transmitted to any server.
What is JSONC (JSON with Comments)?
JSONC stands for "JSON with Comments," a variant popularized by Visual Studio Code and TypeScript. Unlike standard JSON, JSONC allows single-line (//) and multi-line (/* */) comments, plus trailing commas. This makes it practical for configuration files like tsconfig.json and settings.json where developers annotate settings and temporarily disable options.
This formatter processes JSONC by stripping comments and trailing commas, then applying standard JSON formatting. The result is valid strict JSON that any parser can handle. This is useful when sharing configuration with a system that does not support comments, or when validating the data portion of a commented config file.
{
// compiler options
"target": "es2020",
"module": "commonjs",
/* experimental */
"decorators": true,
}
{
"target": "es2020",
"module": "commonjs",
"decorators": true
}
Get the most out of this tool
- Use JSONC for VS Code settings, TypeScript config, and ESLint config — these tools support comments natively.
- This formatter strips comments and outputs strict JSON — useful for validating the data portion of commented configs.
- Keep comments in your source JSONC files but use this tool when you need clean JSON for deployment or sharing.
Understanding JSONC — JSON with Comments
JSONC (JSON with Comments) is an informal extension to standard JSON that adds support for // single-line comments and /* */ block comments. It was popularized by Microsoft's VS Code, which uses JSONC for all its configuration files — settings.json, launch.json, tasks.json, and keybindings.json. The rationale is simple: configuration files are maintained by humans who benefit from the ability to document their choices inline.
Standard JSON (RFC 8259) explicitly forbids comments. Douglas Crockford, the creator of JSON, intentionally omitted comments to prevent comments from being used as parsing directives — a practice that had caused compatibility problems with other data formats. However, the distinction between data serialization (where comments are unnecessary) and configuration files (where comments are essential) means that JSON's no-comment rule causes practical friction in the configuration file use case.
JSONC differs from JSON5 in scope. JSONC adds only comments and typically allows trailing commas — it does not add unquoted keys, single-quoted strings, hexadecimal numbers, or the other extensions that JSON5 provides. This narrower scope makes JSONC files almost valid JSON — they fail standard JSON parsing only because of comments and trailing commas, both of which are easy to strip with a preprocessor.
The TypeScript compiler's tsconfig.json accepts JSONC syntax, allowing developers to comment their TypeScript configuration. This makes complex tsconfig.json files — which can contain dozens of compiler options — much more maintainable, with inline comments explaining the purpose of options like "strict", "moduleResolution", and "paths". ESLint configuration files also support JSONC through dedicated parsers.
VS Code's built-in JSONC support provides syntax highlighting for comments and trailing comma warnings. The editor uses a permissive JSONC parser that gracefully handles commented-out sections and trailing commas while still providing IntelliSense, schema validation, and auto-completion based on JSON Schema definitions. This model of "lenient parsing for human-authored files" is increasingly common in developer tooling.
Converting JSONC to standard JSON requires stripping comments and trailing commas without corrupting the remaining JSON structure. A naive text replacement approach fails on edge cases: // inside a string value should not be treated as a comment, and */ inside a string should not end a block comment. A proper JSONC-to-JSON converter uses a state machine that tracks whether the parser is inside a string, a single-line comment, or a block comment before deciding how to handle each character.
The JSONC format, while not an IETF standard, has a well-maintained reference implementation at the jsonc-parser npm package developed by the VS Code team. This package provides a fault-tolerant JSONC parser used by VS Code itself, with APIs for parsing JSONC text, editing JSONC documents while preserving comments, and converting JSONC to JSON. It is the de facto implementation for Node.js projects that need JSONC support.
When developers use JSONC
settings.json, launch.json, tasks.json, extensions.json — use JSONC. Developers rely on comments to document workspace settings, explain debug configurations, and mark settings as environment-specific before committing the config to version control.
tsconfig.json supports JSONC syntax. Teams use comments to document why specific compiler options are enabled or disabled, explain path alias mappings, and annotate differences between base configurations and environment-specific overrides.
JSONC pitfalls to avoid
- Sending JSONC directly to JSON APIs: REST APIs and most parsers expect standard JSON. A JSONC file with comments will cause a parse error when submitted to an API. Always strip comments before sending JSONC content to external services or standard JSON parsers.
- Using JSONC for data interchange: JSONC is a configuration file format, not a data interchange format. Data exchanged between systems should use standard JSON. Reserve JSONC for files that humans author and maintain — not for data flowing between programs or services.
- Comments inside string values being stripped: A naive comment stripper that removes everything after
//on a line will incorrectly strip text from string values containing//— for example, a URL like"https://example.com". Always use a proper JSONC parser that tracks string boundaries when processing JSONC files. - Assuming all JSON parsers accept trailing commas: Standard JSON parsers strictly reject trailing commas, even though they are harmless syntactically. JSONC allows trailing commas, but converting JSONC to JSON requires removing them. Do not rely on lenient parser behavior in production — always convert properly.
Additional frequently asked questions
Is JSONC an official standard?
JSONC is not an official IETF standard. It is an informal format popularized by VS Code and Microsoft. There is no RFC or specification document for JSONC — it is defined by the behavior of the jsonc-parser npm package maintained by the VS Code team. For formal interoperability, use standard JSON (RFC 8259).
What is the difference between JSONC and JSON5?
JSONC adds only comments and trailing commas to standard JSON. JSON5 is a broader superset that additionally supports unquoted keys, single-quoted strings, hexadecimal numbers, Infinity, NaN, and multi-line strings. JSONC is essentially a strict subset of JSON5. VS Code uses JSONC; Babel and some build tools use JSON5.
How do I use JSONC in my Node.js project?
Install the jsonc-parser package from npm, which is developed and maintained by the VS Code team. It provides parse() for converting JSONC text to a JavaScript object, stripComments() for converting JSONC to standard JSON, and utilities for safely editing JSONC documents while preserving existing formatting and comments.
Can tsconfig.json use JSONC syntax?
Yes — the TypeScript compiler (tsc) uses a JSONC-aware parser for tsconfig.json, so both // comments and trailing commas are allowed. This is why VS Code does not show errors for comments in tsconfig.json. However, if you read tsconfig.json with JSON.parse() in a script, comments will cause a parse error.