AZ Tools

JS Object ↔ JSON

Convert

Accepts the loose syntax you write in actual JS: unquoted identifier keys, single quotes, trailing commas, line comments. Emits canonical JSON (or, in the reverse direction, a clean JS literal that matches what you'd type by hand). Useful for turning copied dev-console output into something a JSON parser will accept, or for prettifying API responses for inclusion in source code.

Output
{
  "name": "Alice",
  "age": 30,
  "email": "alice@example.com",
  "roles": [
    "admin",
    "editor"
  ],
  "address": {
    "city": "Seoul",
    "zip": "04524"
  },
  "active": true,
  "bio": null
}

JS → JSON evaluates the input as a JS expression — only use on your own data.

How to use

  1. Paste your JS object literal or JSON.
  2. Pick the direction — JS → JSON wraps values strictly; JSON → JS unquotes identifier keys and prefers single quotes.
  3. Copy the output. Indent stays consistent.

Frequently asked questions

How is it parsed?
JS → JSON uses `new Function('return (…)')` inside the page. That's safe to feed your own data into; don't paste untrusted source code here.
What about functions, dates, or RegExps?
JSON can only carry strings, numbers, booleans, null, arrays, and plain objects. The converter rejects anything else with an explicit error rather than silently dropping it like `JSON.stringify` would.
Why prefer single quotes for JS output?
It matches the prevailing style in modern JS codebases (and is what Prettier emits by default). Flip the toggle if you'd rather see double quotes.

Related tools