# JSON Formatter

> Format JSON with 2-space, 4-space or tab indentation, or minify it; invalid JSON gets an error message. Runs in your browser; your data never leaves it.

- Type: Tools
- Category: Formatter
- Published: 2026-04-01
- Updated: 2026-08-30
- Tags: json, formatter
- Source: https://muhammetsafak.com/engineering/tools/json-formatter/
- Language: en-US
- Author: Muhammet Şafak

---
> This tool runs in your browser. No data leaves your device.

A plain formatter built on `JSON.parse` and `JSON.stringify`. The indent size is
configurable (2 spaces, 4 spaces, or tab). For invalid JSON it returns a clear error
message.

## Where JSON.parse is strict

JavaScript's built-in parser follows RFC 8259:

- **Keys must be double-quoted.** `{name: 'x'}` is invalid; `{"name": "x"}` is valid.
- **No trailing commas.** `[1, 2, 3,]` is rejected.
- **No comments.** `// note` or `/* ... */` is not accepted.

These three are where developers get tripped up most often. If you need all three,
you're really using JSON5. JSONC adds comments, but trailing commas are optional there
and unquoted keys are still not allowed — either way, this tool is for strict JSON.

## Minify vs Format

- **Format** — for readability. Meaningful in diffs.
- **Minify** — to shrink payload size. For HTTP bodies or WebSocket frames.

Both represent the same data; the only difference is whitespace.

## Privacy

The JSON you paste is processed entirely in your browser. It is never sent to this site's
backend or any other service.
