JavaScript Object to JSON Converter
Convert a JavaScript object literal or JSON5 to strict JSON: unquoted keys, single quotes, comments and trailing commas are all handled.
Free · No sign-up · Your inputs stay in your browser
Input
Convert a JavaScript object or JSON5 to JSON
Output
JSON
176 characters
Reads what JSON.parse refuses: comments, unquoted keys, single quotes, trailing commas, hex numbers and a leading export default or const x =. undefined, NaN and Infinity have no JSON form, so they become null. Template literals are read as plain strings; ${} is not evaluated.
Runs in this browser. Nothing you paste is sent to a server.
About this tool
Method, assumptions, practical next steps, and limits.
Why JSON.parse rejects it
JSON is deliberately smaller than JavaScript: keys must be double-quoted, there are no comments and no trailing commas (RFC 8259). Config copied out of a .js file, a browser console or a JSON5 file such as tsconfig.json usually breaks one of those rules, which is why pasting it into an API client fails.
Nothing is evaluated
The input is parsed, never run with eval, so pasting untrusted code here is safe. That also means expressions are not computed: a value like 60 * 60 or process.env.PORT is reported as an error rather than guessed.