araç köşesi

JSON5 to JSON Converter and Validator

Validate JSON5 with comments, single quotes or trailing commas and convert it to strict JSON

Your data stays with you. Conversion happens inside the browser; nothing is sent to a server.

How it works

A tsconfig.json, VS Code's settings.json or a Babel config often contains comment lines, single quotes and a comma after the last item. Those files work in their own program, but a tool, an API or JSON.parse that expects strict JSON rejects them with an "Unexpected token" error. Paste the text into the left box. The tool reads it with the JSON5 rules and writes strict JSON on the right: unquoted keys (target:) get double quotes, single-quoted strings like 'ES2020' switch to double quotes, trailing commas are removed, hex numbers like 0x10 become 16, and // and /* */ comments are dropped. The result line gives the output size in bytes and how many comments were removed. If the text is not valid JSON5 either, for example a quote is left open, nothing is converted and you see the line and column of the error. JSON has no Infinity or NaN, so those are written as null and flagged separately in the result line.

This tool is also known as json5 to json, json5 validator, json5 formatter, jsonc to json, remove comments from json, json with comments to json.

What is JSON5?

JSON5 is an extension of JSON that makes it easier to write by hand, based on how JavaScript writes objects. Unlike strict JSON it allows // and /* */ comments, single-quoted strings, unquoted keys, a comma after the last item, hex numbers starting with 0x, and the values Infinity and NaN. Babel and some build tools read JSON5 config files, but the browser's JSON.parse cannot.

What is Strict JSON?

Strict JSON is JSON that follows the RFC 8259 standard exactly: keys and strings use double quotes only, there are no comments, no comma after the last item, and numbers are decimal. Every programming language's JSON library and every API reads this form. Converting a config file to strict JSON before handing it to another program prevents "Unexpected token" errors.

What is the difference between JSON5 and JSON?

JSON is a strict format built for exchanging data: every key in double quotes, no comments, no trailing comma. JSON5 keeps the same data model but relaxes the writing rules: comments, single quotes, unquoted keys, trailing commas and hex numbers are allowed. Every JSON document is valid JSON5, but not the other way round. That is why JSON5 is used for config files that people edit, and JSON for moving data between programs.

Why are my comments missing from the output?

Strict JSON cannot hold comments; the standard leaves them out on purpose. So converting JSON5 to JSON necessarily drops notes written with // and /* */. The tool tells you how many comments it removed so you notice the information is gone.

If you will keep editing the file by hand, keep the original JSON5 file and give the JSON output only to the place that needs strict JSON (an API request, a database field, a script that uses JSON.parse). If you want the comments to stay, YAML is a good choice: it holds comments and the same data as JSON.

When is JSON5 fine and when is JSON required?

JSON5 and JSON with comments (JSONC) are for config files people edit by hand: you can write notes and leave a trailing comma so adding or removing a line is easy. TypeScript, VS Code and Babel accept this relaxed form in their own files.

When data moves between programs, strict JSON is required: the browser's JSON.parse, REST APIs and most language libraries treat comments or single quotes as errors. This page moves text from the first world to the second; for strict JSON that only needs new indentation, the JSON formatter is the better fit.

  • tsconfig, VS Code, Babel config file → can stay JSON5 / JSONC
  • API request, JSON.parse, database → strict JSON (this page's output)
  • Already strict JSON, only indentation → the JSON formatter

Frequently asked questions

How do I convert JSON with comments to normal JSON?

Paste the text into the left box on this page. // and /* */ comments are removed, single quotes become double quotes, trailing commas are deleted, and strict JSON appears on the right. Copy it or download it as a .json file.

Are JSON5 and JSONC the same thing?

Close, but not the same. JSONC, used by VS Code, only allows comments and, in some places, trailing commas. JSON5 goes further: single quotes, unquoted keys, hex numbers and multi-line strings are allowed too. Every JSONC file is valid JSON5, so this tool reads both.

What happens to Infinity or NaN values?

JSON does not know these values, and JSON.stringify writes them as null. The tool does not do this silently: the result line tells you how many values became null. If you must keep them, store them as text ("Infinity").

Is my data sent to a server?

No. Conversion runs entirely in your browser; the config file or data you paste never leaves this page and is not stored anywhere.