JSON Formatter

Beautify, minify and validate JSON with a precise error position.

Input
Output
Send output to

Formatting JSON without handing it to a stranger

A JSON formatter is the most-reached-for tool in a developer's day and the one people think about least. The input is usually an API response, and an API response usually carries a bearer token, a customer email, an internal hostname, or all three. Pasting that into a page that POSTs it to a backend puts a copy of it somewhere you cannot audit and cannot delete.

This formatter never makes that request. It calls JSON.parse and JSON.stringify — the parser already built into your browser, the same one your application uses — and writes the result back into the textarea. You can verify it in ten seconds: open the network tab and format something, or turn off your network entirely and watch the tool keep working.

Reading a parse error

When JSON fails to parse, the error is reported with the line, column and character offset, plus the surrounding text so you can see the problem in context. Four causes account for almost everything:

  • Trailing commas — legal in JavaScript, illegal in JSON. The most common single cause.
  • Single quotes — JSON strings are double-quoted, always.
  • Unquoted keys{name: 1} is a JavaScript object literal, not JSON.
  • Comments — no JSON dialect accepts // or /* */. If you need them, you want JSON5 or YAML.

Minify before you ship, format before you read

Minified JSON removes every byte of whitespace. On a large API payload that is a real reduction in transfer size, and it is what you want going over the wire. It is also unreadable, which is what this tool is for: expand it to read it, collapse it to ship it. Neither direction loses information, so it is safe to round-trip.

Treat any tool that asks you to upload configuration as if it keeps a copy. Usually it does — not maliciously, just in a request log nobody remembered to turn off.

Questions people actually ask

Is my JSON sent to a server?
No. Formatting uses the browser's built-in JSON.parse and JSON.stringify. The page makes no network request with your input, which is why it keeps working with your connection off.
Why does my JSON fail to parse when it looks correct?
The most common causes are trailing commas, single quotes instead of double quotes, unquoted keys, and comments. All four are valid JavaScript but invalid JSON. The error message points at the exact character offset.
What indentation does the formatter use?
Two spaces by default, switchable to four spaces or tabs. The choice is remembered on this device.
navigate open esc close