>_devtools

JSON to JavaScript Object Converter

Convert JSON to a JavaScript object literal with unquoted keys, your quote style, and an export wrapper.

What this does

Converts JSON into a JavaScript object literal: keys are unquoted where they are valid identifiers, strings use the quote style you prefer, and the result can be wrapped as aconst, export default, or module.exports statement. Handy for fixtures, mocks, and config files where JSON's strict syntax is unnecessary.

Example

Input

{
  "id": 42,
  "name": "Ada",
  "verified": true,
  "tags": [
    "admin",
    "dev"
  ],
  "orders": [
    {
      "sku": "A1",
      "qty": 2
    },
    {
      "sku": "B2",
      "qty": 1,
      "note": "gift"
    }
  ]
}

Output with default options

const data = {
  id: 42,
  name: 'Ada',
  verified: true,
  tags: [
    'admin',
    'dev',
  ],
  orders: [
    {
      sku: 'A1',
      qty: 2,
    },
    {
      sku: 'B2',
      qty: 1,
      note: 'gift',
    },
  ],
};

Details

  • Keys such as b-c, 1st, or ones with spaces stay quoted. Turn on Always quote keys to quote everything.
  • A key named __proto__ is written as a computed key (["__proto__"]) so it becomes a normal property instead of changing the object's prototype.
  • Strings are escaped for the chosen quote style, including newlines, backslashes, and control characters, so the output always evaluates to the original data.
  • Choose 2 spaces, 4 spaces, or tabs, and whether to add trailing commas.

Things to know

Numbers are taken from JSON.parse, which stores them as 64-bit floats, so integers beyond 253 lose precision exactly as they would in JavaScript. If you need the other direction, or want types, see JSON to TypeScript.

Privacy

The conversion runs in your browser. The JSON is never uploaded.