Skip to main content
NyankoTools

JSON5 ⇔ JSON Converter

Paste JSON5 (JavaScript-style object literals with comments, trailing commas, unquoted keys, single-quoted strings, hex numbers, Infinity and NaN) to get plain JSON. Or go the other way and turn JSON into tidy JSON5 with unquoted keys and single quotes. To validate or pretty-print the resulting JSON, use the JSON Formatter.

🔒 Runs in your browser · Your data is never sent to a server

Notes

  • JSON has no comments, so JSON5 comments are lost when converting to JSON. Hex numbers become decimal and single quotes become double quotes.
  • JSON has no Infinity or NaN, so "JSON5→JSON" replaces them with null or a string. In "JSON→JSON5" they are accepted as input and kept in the output.
  • Integers beyond 2^53 cannot be represented exactly by JavaScript numbers and may be rounded.
  • If a key appears more than once, the last value wins.

Glossary

JSON5

An extension of JSON that allows comments, trailing commas, unquoted keys, single-quoted strings, hex numbers and more. It targets hand-written config files, and every valid JSON document is also valid JSON5.

Trailing comma

A comma after the last item of an array or object. It keeps diffs small when you add or reorder items, but plain JSON rejects it.

Prototype pollution

An attack that abuses keys such as "__proto__" to modify the shared prototype of JavaScript objects. This tool treats such keys as ordinary data.

FAQ

What is the difference between JSON5 and JSON?

JSON5 is a superset of JSON that allows comments, trailing commas, unquoted keys, single-quoted strings, hex numbers, Infinity and NaN. Plain JSON rejects all of these, so convert to JSON here before handing the data to an API or parser.

Can I paste a JavaScript object literal as is?

Yes, as long as it contains only data, such as unquoted keys and single-quoted strings. Anything that must be evaluated as code, like functions, variables, template literals or regular expressions, is not supported. The input is never executed; it is read by a dedicated parser.

What happens to Infinity and NaN in JSON?

JSON cannot represent them, so "JSON5→JSON" replaces them with null or a string such as "Infinity". The number of replaced values is shown below the result.

How are syntax errors reported?

Errors show the line and column along with the cause. Common culprits are a missing closing bracket or quote, a missing colon between a key and its value, and a missing comma.

Share this page

↑↓ Select Enter Open Esc Close