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.
{
"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
- Paste your JS object literal or JSON.
- Pick the direction — JS → JSON wraps values strictly; JSON → JS unquotes identifier keys and prefers single quotes.
- 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
CSS Unit Converter
Convert between px, rem, em, pt, vw, vh, and % using your own base font size and viewport.
JSON ↔ YAML Converter
Convert JSON to YAML or YAML to JSON — pick the indent and copy the result.
Data Size Converter
Convert between bytes, KB, MB, GB, TB — in decimal (1000) or binary (1024).
Roman Numeral Converter
Convert between Arabic numbers and Roman numerals from 1 to 3999.
Number Base Converter
Convert numbers between binary, octal, decimal, and hexadecimal.
Unit Converter
Convert length, weight, temperature, area, volume, speed, and time.