How to use the JSON5 to JSON converter
- Paste JSON5 or JSON with comments into the left pane, such as a
tsconfig.json,.vscode/settings.json,.babelrcor a JSON5 config file. Strict JSON appears as you type. - Indent: 2 spaces, 4 spaces, tabs, or Minify for a single line.
- Copy or Download the result as
output.json.
A syntax error is reported with its line and column, and the line is highlighted.
Example
// tsconfig.json (JSON with comments)
{
"compilerOptions": {
"strict": true, // keep this on
"paths": { "@/*": ["./src/*"], },
},
include: ['src', 'tests'],
maxRetries: 0x10,
}
becomes
{
"compilerOptions": {
"strict": true,
"paths": { "@/*": ["./src/*"] }
},
"include": ["src", "tests"],
"maxRetries": 16
}
What gets changed
- Comments are removed, both
// lineand/* block */comments. - Trailing commas are dropped after the last item of objects and arrays.
- Keys get double quotes and single-quoted strings become double-quoted strings.
- Hexadecimal and other number forms such as
0x10,.5or+1become plain decimal numbers. - Infinity and NaN become null, with a warning.
- Integers beyond 2^53 lose precision, and a warning shows the first one so you can quote it in the source.
When to use it
- Tools that only read strict JSON.
jq, many JSON Schema validators and older parsers reject comments and trailing commas. - Merging or diffing configs. Strip the comments, then compare two versions with JSON Diff.
- Checking a file. Once it is strict JSON, the JSON Formatter can pretty-print it, and the JSON Validator reports duplicate keys.
Why strict JSON still matters
JSON with comments is convenient for humans, which is why TypeScript, VS Code, ESLint and many other tools accept it in their own config files. But most JSON parsers, including JSON.parse in JavaScript, Python’s json module and Go’s encoding/json, reject comments and trailing commas with an error. Converting to strict JSON is the safest way to pass such a file to another program, to store it in a database column, or to send it in an API request. Keep the commented version as your source and generate the strict one when you need it.
If the input is not real JSON5 but broken JSON, for example cut-off output from a language model, use JSON Repair instead. To go from JSON5 to YAML, TOML or another format in one step, use the Data Format Converter.
Frequently asked questions
What is the difference between JSON5 and JSONC?
JSONC is JSON with comments, the format of tsconfig.json and VS Code settings: // and /* */ comments, and usually trailing commas. JSON5 goes further and also allows unquoted keys, single-quoted strings, hexadecimal numbers, leading or trailing decimal points, a leading plus sign and Infinity or NaN. This tool reads both, because JSONC is a subset of JSON5.
Why did a large number change?
The JSON5 parser reads numbers as JavaScript numbers, which hold integers exactly only up to 2^53. Longer integers are rounded, and the tool warns you with an example. Quote IDs like these as strings in the source to keep every digit.
What happens to Infinity and NaN?
Strict JSON has no way to write them, so they become null and a warning says how many values were affected.
How is this different from JSON Repair?
This tool parses valid JSON5 strictly and reports real syntax errors with their line and column. JSON Repair guesses at fixes for broken JSON, such as missing brackets or truncated output from a chatbot. Use this one when the file is meant to be JSON5 or JSONC.
Is my file uploaded?
No. Parsing runs in your browser and nothing you paste leaves your device.
Last updated