About this tool
The JS Object to Strict JSON tool repairs a loose JavaScript or JSON5-style object literal into strict, valid JSON. It is built on a hand-written tokenizer — it never uses eval or new Function — so it is safe under a strict Content Security Policy and safe to paste untrusted text into. Everything runs in your browser.
It accepts the things real JSON rejects: unquoted identifier keys, single-quoted strings, trailing commas before ] or }, // line and /* block */ comments, hexadecimal (0xFF), octal and binary literals, leading-plus and leading-dot numbers (+1, .5), and the values undefined, NaN, and Infinity. Keys are re-quoted with double quotes, strings are re-escaped correctly, comments and trailing commas are stripped, and numbers are normalized to plain JSON numbers. You choose how to treat undefined (convert to null or drop the key) and non-finite numbers (convert to null or raise an error), then the value is re-serialized with JSON.stringify at your chosen indent — 2 spaces, 4 spaces, tabs, or minified.
When the input cannot be parsed, the tool reports the first syntax error with its line and column so you can find the problem quickly. This complements a strict JSON formatter, which simply rejects loose input — here the goal is to salvage copied console output, config snippets, and hand-edited objects into JSON that any parser will accept.