JSONC to JSON Converter
Convert JSON with comments (JSONC) or JSON5 to standard JSON. Perfect for preparing config files for production or API use.
JSONC/JSON5 Features We Support
// comment/* ... */{"a": 1,}{key: "value"}{'a': 'b'}0xFFWhat is JSONC?
JSONC (JSON with Comments) is an extension of JSON that allows JavaScript-style comments. It's widely used in configuration files where documentation is helpful:
- VS Code settings —
settings.json,tasks.json - TypeScript config —
tsconfig.json - ESLint config —
.eslintrc.json - And many more...
Standard JSON parsers don't support comments, so you need to strip them before using the data in production code or sending to APIs.
JSONC vs JSON5 vs Standard JSON
| Feature | JSON | JSONC | JSON5 |
|---|---|---|---|
Single-line comments (//) | ❌ | ✅ | ✅ |
Multi-line comments (/* */) | ❌ | ✅ | ✅ |
| Trailing commas | ❌ | ✅ | ✅ |
| Unquoted keys | ❌ | ❌ | ✅ |
| Single quotes | ❌ | ❌ | ✅ |
| Hex numbers | ❌ | ❌ | ✅ |
| Multi-line strings | ❌ | ❌ | ✅ |
This tool converts both JSONC and JSON5 to standard JSON, handling all the features listed above.
Comment Syntax
Single-line comments
Start with // and continue to the end of the line:
{
"port": 3000, // Server port
"host": "localhost" // Only for development
}Multi-line comments
Enclosed in /* */, can span multiple lines:
{
/*
* Database configuration
* Update these values for production
*/
"database": {
"host": "localhost",
"port": 5432
}
}Why Remove Comments?
While comments are great for documentation, they cause problems in certain contexts:
- JSON.parse() fails — JavaScript's built-in parser doesn't support comments
- APIs reject them — Most REST APIs expect standard JSON
- Smaller payloads — Comments add bytes that aren't needed at runtime
- Interoperability — Other languages' JSON parsers don't support comments
Programmatic Conversion
JavaScript/Node.js
// Option 1: Use jsonc-parser (VS Code's parser)
import { parse } from 'jsonc-parser';
const jsonc = '{"a": 1} // comment';
const result = parse(jsonc);
// Option 2: Use strip-json-comments
import stripJsonComments from 'strip-json-comments';
const json = stripJsonComments(jsonc);
const data = JSON.parse(json);
// Option 3: Use json5 library
import JSON5 from 'json5';
const data = JSON5.parse('{"a": 1,}'); // handles trailing commas tooPython
# Using pyjson5 library
import pyjson5
data = pyjson5.load(open('config.json5'))
# Or commentjson for just comments
import commentjson
data = commentjson.load(open('config.jsonc'))Command Line
# Using Node.js
npx strip-json-comments-cli config.jsonc > config.json
# Using jq (after stripping comments manually)
cat config.json | jq '.'Best Practices
- Use JSONC for config files — Comments make configs self-documenting
- Convert before deployment — Strip comments in your build process
- Don't store secrets in comments — They're still in the file!
- Keep comments concise — Long comments belong in external docs
Common Use Cases
VS Code Settings
VS Code's settings.json supports JSONC, but if you need to process these settings programmatically, you'll need to strip the comments first.
TypeScript Configuration
tsconfig.json supports comments, but tools that read it programmatically might not. Use this converter to create a comment-free version.
API Requests
If you're copying configuration from a JSONC file to use in an API request, this tool removes the comments so the request doesn't fail.
Related Tools
- JSON Validator — Validate the converted JSON
- JSON Repair — Fix other JSON syntax issues
- JSON Pretty Print — Format the output
- JSON Minify — Compress for production
Frequently Asked Questions
Why doesn't JSON support comments?
Douglas Crockford (JSON's creator) intentionally excluded comments to prevent them from being used for parsing directives, which would complicate the format. JSON was designed to be simple and unambiguous.
Can I add comments back after conversion?
No — once comments are stripped, the information is lost. Keep your source JSONC file and only convert to JSON when needed for deployment or APIs.
Is JSONC the same as JSON5?
No. JSONC only adds comments and trailing commas. JSON5 is a larger superset that also allows unquoted keys, single quotes, hex numbers, and multi-line strings. This tool handles both.
Will this tool modify my data?
Only comments and trailing commas are removed. The actual data values remain unchanged. However, formatting (whitespace, indentation) may change.