toolqik

204 · JavaScript

JSON to JavaScript

Turn JSON into a clean JavaScript object literal: unquoted keys, your quote style and an export.

Runs in your browser
Quotes
Indent
Options
JavaScript

  

About this tool

JSON is valid JavaScript syntax, but it doesn’t look like code people write: every key is quoted and strings use double quotes. Paste JSON to get an idiomatic object literal you can drop into a source file, a config or a test fixture, ready to export.

What changes

  • Keys that are valid identifiers lose their quotes (name:); keys like "first-name" or "2fa" keep them.
  • Strings use your preferred quotes, with escaping adjusted.
  • Trailing commas make future diffs cleaner, as Prettier does by default.
  • Object.freeze (applied deeply) or TypeScript’s as const make the data read-only.

Integers too large for JavaScript to represent exactly (over 253) become BigInt literals (123n) so no digits are lost. A "__proto__" key is written as a computed key so it stays an ordinary property.

FAQ

Is JSON valid JavaScript?

Yes, since ES2019 JSON is a subset of JavaScript syntax. This tool rewrites it in the style people usually write, with unquoted keys and single quotes.

Why do some keys keep their quotes?

Keys that aren’t valid identifiers, such as "first-name" or "2fa", must be quoted in an object literal.

What does Object.freeze do?

It makes an object read-only. The tool freezes every nested object and array, not just the top level.

Can I convert JavaScript back to JSON?

Use the JavaScript Object Inspector, which evaluates an object literal and can show it as JSON.

Is my data uploaded?

No. The conversion runs in your browser.

esc
↑↓ navigate↵ open