JS Object ↔ JSON
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 to JS Style Object Converter
Convert a CSS declaration block into a React/JS inline style object, in your browser.
XML ↔ JSON Converter
Convert XML to JSON and back, with full attribute support, configurable attribute prefix and text key. Browser-native DOMParser handles namespaces, CDATA, comments.
String Escape Converter
Escape a string for 10 contexts at once — JavaScript, JSON, HTML entities, URL, SQL, regex, Bash (single/double quote), C string, Unicode \u escapes. Copy whichever you need.
JSON ↔ YAML Converter
Convert JSON to YAML or YAML to JSON — pick the indent and copy the result.
CSV → HTML / Markdown / JSON Table
Convert CSV to an HTML `<table>`, a Markdown table, or a JSON array of objects — auto-detects the delimiter.
Fixed-Width Text Parser to CSV / JSON
Split fixed-width / fixed-column text into fields by column widths and export as CSV or JSON, in your browser.