Convert a JavaScript object to valid JSON
Developers constantly copy an object out of a code file or a console log and need it as strict JSON — for a config file, an API request body, or a test fixture. The problem is that a JavaScript object literal is not JSON: it may use unquoted keys, single quotes, trailing commas, and even comments, none of which JSON allows.
This converter fixes all of that. Paste your object on the left and get clean, double-quoted, strictly valid JSON on the right, updating live as you type.
What it accepts
- Unquoted keys —
{ name: 'Ada' }becomes{ "name": "Ada" }. - Single quotes — normalised to double quotes.
- Trailing commas — silently removed.
- Line and block comments — stripped before conversion.
Choose a 2 or 4 space indent for readable output, or Minified for a single compact line, then press Copy JSON.
Private by design
The conversion runs entirely in your browser: your object literal is evaluated locally, exactly as it would be in your own developer console, and the result never leaves the tab. Nothing you paste is uploaded, logged or stored, so it is safe for objects that contain internal field names or sample data. If the input is not a valid object expression, the tool shows the precise parse error so you can fix it.