JSON5 to JSON Converter

Convert JSON5 or JSON with comments (JSONC) to strict JSON: comments, trailing commas and unquoted keys handled.

Runs in your browser. Nothing is uploaded.

How to use the JSON5 to JSON Converter

  1. Paste JSON5 or JSON with comments into the left box, open a .json5 or .jsonc file, or press Load example.
  2. Strict JSON appears on the right as you type.
  3. Choose 2 spaces, 4 spaces, tabs or a minified single line for the output.
  4. If the input can't be read, the message shows the line and column of the problem.
  5. Copy the result or download it as a .json file.

Why convert JSON5 or JSONC to JSON?

Strict JSON is easy for machines but strict for people: no comments, no trailing commas, quotes around every key. That’s why many tools accept relaxed variants for hand-written configuration. TypeScript’s tsconfig.json, VS Code’s settings.json and many linters read JSON with comments (JSONC), and some projects use the more flexible JSON5 format.

The trouble starts when that file has to be read by something that only understands real JSON: a script using JSON.parse, a different programming language, a validator, or an API that takes a config upload. This converter turns the relaxed file into strict JSON so it works everywhere.

What gets converted

  • Comments (// and /* */) are removed
  • Trailing commas after the last item are dropped
  • Unquoted keys such as name: become "name":
  • Single-quoted strings become double-quoted, with any inner quotes escaped
  • Hexadecimal numbers like 0xff and numbers such as .5 or +3 become ordinary decimals
  • Multi-line strings written with a backslash at the end of the line are joined
  • Infinity and NaN become null, and you’re told which paths changed

Helpful errors

If part of the file isn’t valid even as JSON5, such as a missing comma between two properties, you get the line and column of the problem and the line is highlighted in the editor. Fix it and the output updates straight away.

Already JSON?

Every JSON document is also valid JSON5. If you paste strict JSON, the tool simply reformats it in your chosen style and tells you no conversion was needed. It works entirely in your browser, so private configuration files never leave your computer.

Frequently asked questions

What is the difference between JSON5, JSONC and JSON?

JSON is the strict format every parser understands. JSONC is JSON plus comments (and usually trailing commas), used by files such as tsconfig.json and VS Code settings. JSON5 goes further and also allows unquoted keys, single-quoted strings, hexadecimal numbers, leading or trailing decimal points, and multi-line strings.

Are my comments kept?

No. Strict JSON has no comment syntax, so comments are removed in the output. Keep your original file if the comments matter, and use the converted version only where strict JSON is required.

What happens to Infinity and NaN?

JSON5 allows them but JSON cannot represent them, so they are converted to null and the message lists exactly which values changed. Decide whether null is acceptable or use a very large number or a string instead.

Can I convert JSON back to JSON5?

Any valid JSON is already valid JSON5, so no conversion is needed. To make it look more like hand-written JSON5, you would remove quotes from keys by hand.

Is my file uploaded?

No. Conversion happens in your browser, and nothing is sent to a server.

Tutorials