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.
This tool runs in your browser. No data leaves your device.
How it works
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.
// noteor/* ... */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.
How it works
Your text goes through JSON.parse first. If that throws, you get the parser’s error
message and nothing is rewritten. If it succeeds, the resulting value is serialized again
with JSON.stringify and the indent you picked, or with no indent when you minify.
Because the round trip goes through JavaScript values, numbers can change. They are
converted to JavaScript numbers while parsing, so a large integer such as
12345678901234567890 may lose precision; MDN’s advice is to carry such values as
strings.
Leading and trailing whitespace is trimmed, and empty input clears the output. The tool
does not use a reviver: the context.source route MDN shows for large numbers is not
there, so a value that already lost precision is written out as it was left. The error
message is the browser’s own JSON.parse error; the tool does not rewrite it.
Check a payload with long identifiers after formatting: if an ID changed its last digits, the problem is the number type, not the formatter.
Privacy
The JSON you paste is processed entirely in your browser. It is never sent to this site’s backend or any other service.