JSON Cleaner

Clean up near-JSON: fix comments, single quotes, unquoted keys and trailing commas, and see exactly what was changed.

What It Does

This cleaner takes text that is almost JSON — a JavaScript object literal, a tsconfig with comments, a payload someone edited by hand — and makes it valid JSON. It removes comments and trailing commas, converts single-quoted strings to double quotes, and quotes bare keys. Then it lists each kind of fix it applied, so you know what changed rather than trusting a black box. Input that is already valid is just formatted.

When to Use It

  • You copied an object from JavaScript source code and need it as JSON for an API call.
  • A config file like tsconfig.json or a VS Code settings file has comments and a strict parser rejects it.
  • A hand-edited fixture has a trailing comma that breaks your test run.
  • You want to see which non-JSON habits a file contains before deciding how to fix it.

Worked Examples

{ name: 'Ada', langs: ['en', 'fr'], }

A JavaScript object literal. Keys are quoted, single quotes become double quotes, and the trailing comma goes — three fixes listed.

{ // compiler options "strict": true, /* recommended */ "target": "es2022" }

Comments in the style of tsconfig.json are removed; the data is unchanged.

{"ok": true}

Already valid. Nothing is changed except formatting, and the notes say so.

Features

Runs as you type
Clear error messages with line and column
Explains what changed and why
One-click copy
Works offline
Nothing uploaded

How to Use

1. Paste your input into the top box. 2. Adjust the options if the page has any — the result updates as you type. 3. Read the notes under the result, then copy it.

Common Mistakes

  • Editing the result by hand and breaking the escaping. If you need to change the content, change the input and run it again — a single stray backslash makes the whole value invalid.
  • Assuming the browser preserved Windows line endings. A pasted CRLF becomes LF in any text box, so a byte-exact comparison with the original file can still differ.
  • Trusting that two documents are equal because they look equal. Key order, whitespace and number formatting differ between serializers; compare parsed values, not text.

Frequently Asked Questions

Everything runs in your browser. Your JSON is never uploaded, logged or stored.

Explore related topics

#JSON