JS Object Literal to JSON
Convert a JS object literal into strict JSON: quote bare keys, turn single quotes into double quotes, strip trailing commas and comments, with support for CJK keys and escape sequences.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
Handles common JS syntax: unquoted keys (ASCII or CJK), single-quoted strings, trailing commas and // or /* */ comments. Template literals, undefined and functions cannot be converted.
Strict JSON
The output is strict JSON, ready for JSON.parse and any other JSON tool.
Paste a JS object literal to see strict JSON
What this tool does
- Turn an object literal copied from code (unquoted keys, single quotes) into strict JSON for an API or config file
- Clean up mock data by dropping trailing commas and comments so tooling can validate it
Example
Input
{name: 'Ada', age: 37, tags: ['dev',],}Output
{
"name": "Ada",
"age": 37,
"tags": [
"dev"
]
}Keys are quoted, single quotes become double quotes and the trailing comma is removed.
Frequently asked questions
Which JS-only syntax is supported?
Unquoted keys (ASCII, CJK or containing dots), single-quoted strings (including \', \n and \uXXXX escapes), trailing commas, and both // and /* */ comments.
What raises an error?
Template literals (`x`), undefined, NaN, functions and arrow functions, spread syntax ...obj, variable references such as {a: someVar} and hex literals like 0x10 — all of them are evaluated at runtime rather than being literals.
Does the conversion change values?
It is a syntax rewrite only: strings are unescaped per JS rules and re-escaped per JSON rules, while numbers and booleans keep their literal form. No types are inferred and no expressions are evaluated (1 + 1 stays as is).
Is the output guaranteed to be valid JSON?
Yes. The rewritten text must pass JSON.parse before it is shown; otherwise the tool reports an error instead of printing a half-converted result.
Keywords:js object to jsonliteral to json