JSON to JavaScript Object Literal Converter

Turns JSON into code you can paste into a JavaScript file: keys that are valid identifiers lose their quotes, strings use your preferred quotes, and you can add a const declaration and trailing commas.

Use the tool

Why this tool exists

JSON is valid JavaScript only by accident. In source code teams usually want unquoted keys, single quotes and a name for the value. Editing that by hand is dull and quotes inside strings are easy to break.

The tool parses your JSON, so invalid input is reported instead of guessed at, and it escapes strings for the quote style you pick. A key named __proto__ is written as a computed key so that it stays a normal property.

How to use it

  1. Paste JSON.
  2. Pick the quote style and indent.
  3. Set a variable name, or clear it for a bare literal.
  4. Copy the result.

Frequently asked questions

Which keys keep their quotes?

Keys that are not valid identifiers, such as first-name or 1abc.

What about numbers like 1e400?

JSON.parse turns them into Infinity. The output keeps what JavaScript read.

Are large integers safe?

No. JSON numbers become JavaScript numbers, so integers over 2^53 lose precision.

Does it support comments or trailing commas in the input?

No, the input must be strict JSON.