JS Object to JSON Converter

Turn a JavaScript object literal into strict, valid JSON instantly.

Free JS object to JSON converter. Paste a JavaScript or JSON5-style object with unquoted keys, single quotes, trailing commas or comments and get strict, valid JSON back. Choose the indent or minify. Runs in your browser, nothing uploaded. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

What is the difference between a JS object and JSON?

A JavaScript object literal is source code — it allows unquoted keys, single quotes, trailing commas, comments and expressions. JSON is a strict data format that requires double-quoted keys and strings, no trailing commas and no comments. This tool rewrites the former into the latter.

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.