JSON5 and JSONC to JSON Converter
Turn config files with comments, single quotes, unquoted keys and trailing commas into strict JSON any parser accepts, or write tidy JSON5 from plain JSON.
Läuft in Ihrem Browser. Ihre Dateien verlassen nie Ihr Gerät. So prüfen Sie es
…
So geht's
- 1Paste the file
Paste JSON5 or JSONC, open a .json5, .jsonc or .json file, or tap Sample.
- 2Pick the output
Tap To strict JSON, To JSON5 or Strip comments only.
- 3Set formatting
Choose indent, key sorting, quotes and trailing commas.
- 4Decide on special numbers
Choose null, string or error for Infinity and NaN.
- 5Read the report
Check the non-JSON features and any duplicate keys.
- 6Copy or download
Copy the result or download it; use the swap button to convert it back.
Über dieses Tool
Strict JSON is deliberately small: double-quoted keys and strings, no comments, no trailing commas. People who edit configuration files by hand want more, and so two relaxed dialects became common. JSON with comments, often called JSONC, is what tsconfig.json, jsconfig.json, VS Code settings and many editors use: plain JSON plus // and /* */ comments and, in practice, trailing commas. JSON5 goes further and allows single-quoted strings, unquoted keys, hexadecimal numbers, leading or trailing decimal points, a plus sign, Infinity and NaN, and strings continued across lines with a backslash. The trouble starts when such a file has to be read by a tool that only understands strict JSON: a CI script using jq, a Python json.load call, a database import or an API. This converter reads JSON5 and JSONC exactly and writes strict JSON, or goes the other way and writes JSON5 with unquoted keys and the quote style you prefer.
Three outputs
To strict JSON parses the full JSON5 grammar and writes standard JSON with your chosen indent, or minified with an indent of zero, and optionally with keys sorted from A to Z, which makes two configs easy to compare. To JSON5 writes keys without quotes where they are valid identifiers, keeps reserved words quoted, uses single or double quotes and can add trailing commas. Strip comments only is for JSONC files you want to keep looking the same: it deletes comments and, if you like, trailing commas, but leaves every line break in place, so line numbers in later error messages still point to the right line.
The feature report
Each conversion lists which non-JSON features the input used and how often: comments, trailing commas, single-quoted strings, unquoted keys, hex numbers, Infinity or NaN, plus signs, loose decimals and line continuations. If the list is empty, the file was strict JSON already. Duplicate keys are reported too; like JavaScript, the parser keeps the last value, which is a frequent cause of settings that seem to be ignored.
Numbers with no JSON form
JSON has no Infinity or NaN. You choose whether they become null, which is what JSON.stringify does, are written as strings, or stop the conversion with an error so that nothing is silently changed.
Limits
Comments cannot exist in strict JSON, so they are lost in that output, and the JSON5 output does not carry them over either; use Strip comments only when you need the rest of the layout. Octal escapes and leading zeros are rejected, as the JSON5 specification requires. Numbers are JavaScript doubles, so integers above 2 to the power 53 lose precision. Hash comments are accepted as a convenience even though JSON5 itself does not define them.
Rechenbeispiel
A developer needs the paths from a tsconfig-style file inside a build script that uses Python's json module. The file has 4 comments, unquoted keys such as compilerOptions, the value 'ES2022' in single quotes, a hex number 0x2, the decimal .75 and trailing commas after the last path and the last include entry. The report lists 4 comments, 4 trailing commas, 1 single-quoted string, 7 unquoted keys, 1 hex number and 1 loose decimal. The strict JSON output has maxNodeModuleJsDepth 2 and ratio 0.75, and json.load reads it without complaint. With Strip comments only, the output keeps 11 lines, so an error at line 6 still means line 6 of the original.
Kurzinfos
- Kategorie: Entwickler & Daten
- Läuft in Ihrem Browser, ohne Anmeldung, ohne Upload.
- Ihre Eingaben bleiben auf Ihrem Gerät.
- Auf Englisch verfügbar.
- Inhalt zuletzt geprüft:
- Offizielle Quelle: JSON5 Data Interchange Format 1.0.0 (spec.json5.org) and IETF RFC 8259
Häufig gestellte Fragen
Is JSONC the same as JSON5?
No. JSONC is JSON plus comments and usually trailing commas. JSON5 is a larger superset that also allows single quotes, unquoted keys, hex numbers and more. This tool reads both.
Will my comments survive?
Not in strict JSON, which has no comments. Use Strip comments only to keep the layout, or keep the original file and generate JSON from it during your build.
Why is a key still quoted in the JSON5 output?
Keys that are not valid identifiers, such as @/* or first-name, and reserved words such as if or class, are quoted so every JSON5 parser reads them the same way.
What happens to Infinity and NaN?
By default they become null, like JSON.stringify. You can write them as strings instead, or make the conversion stop with an error at their position.
How exact are the error positions?
Errors give the line and column where reading stopped, for example a missing comma or an unclosed string, counted in the original text.
Does the tool upload my config?
No. Everything runs in your browser, and the last input is saved only in local storage on this device.
