JSON Formatter
Free JSON formatter and validator. Beautify or minify JSON, catch syntax errors with clear messages, and copy the result.
JSON is the format almost every web API speaks, and it is unreadable when minified into a single line. This tool beautifies it with proper indentation, validates it with a precise error location when it is malformed, and minifies it again when you need the smallest possible payload.
Everything runs in your browser using the native JSON parser, so API responses containing tokens or customer data never leave your device.
How to use the JSON Formatter
Paste your JSON
Minified, pretty-printed or broken — all are accepted.
Format or minify
Formatting adds indentation and line breaks for reading; minifying strips all optional whitespace for transmission.
Fix any errors
If the JSON is invalid, the error message names the problem and the position, so you can jump straight to it.
Copy the result
One click copies the formatted or minified output.
The syntax rules that catch people out
- Keys must be double-quoted strings.
{name: "x"}is JavaScript, not JSON. - Single quotes are invalid. Only
"delimits strings. - No trailing commas.
[1, 2, 3,]is valid JavaScript and invalid JSON — this is the single most common error. - No comments. JSON has no comment syntax at all;
//and/* */both break parsing. - No `undefined`, `NaN` or `Infinity`. Only strings, numbers, booleans, null, objects and arrays.
- Numbers cannot have leading zeros or a trailing decimal point.
01and1.are both invalid.
Reading a parse error
JSON errors report the character position where parsing failed, which is usually just after the actual mistake. A missing comma on line 12 is typically reported at the start of line 13, because that is where the parser realised something was wrong.
When an error position looks correct in isolation, check the line above it. Unclosed brackets behave the same way: the parser reports the end of the document, because that is where it ran out of input while still expecting a }.
Formatted or minified?
| Formatted | Minified | |
|---|---|---|
| Whitespace | Indented, one value per line | None |
| Size | Larger, often by 20%–40% | Smallest possible |
| Use for | Config files, debugging, version control | API responses, storage, network transfer |
| Readability | Good | None |
Commit configuration files formatted — a minified file produces a single unreadable line in every diff. Gzip compression narrows the transfer difference considerably, so minifying matters most for large payloads.
JSON, JSON5 and JSONC
Several relaxed variants exist because strict JSON is awkward to hand-edit. JSONC adds comments and is what VS Code uses for its settings files. JSON5 adds comments, trailing commas, unquoted keys and single quotes.
Both are convenient for configuration written by humans, but neither is accepted by standard parsers. Never send them to an API expecting JSON — strip comments and trailing commas first, which formatting here will reveal.
A note on large numbers
JSON numbers are parsed into JavaScript doubles, which represent integers exactly only up to 2^53 − 1. Larger values — Twitter-style 64-bit IDs, some database primary keys, blockchain amounts — silently lose precision.
The standard fix is to transmit such values as strings. If an ID arrives as "9007199254740993" rather than a bare number, that is why, and it should stay a string.
Frequently asked questions
Why is my JSON invalid?
The most common causes are a trailing comma before a closing bracket, single quotes instead of double, unquoted keys, or comments. The error message gives the position — check the line above it, since errors are reported where parsing failed, not where the mistake is.
Is my data sent to a server?
No. Parsing and formatting use your browser’s built-in JSON engine locally, so API responses containing tokens or personal data are safe to paste here.
Can JSON have comments?
Not in the standard. JSONC and JSON5 add them for hand-edited config files, but standard parsers reject them, so strip comments before sending JSON to an API.
What is the difference between formatting and minifying?
Formatting adds indentation and line breaks so a human can read it. Minifying removes all optional whitespace to make the payload as small as possible. The data is identical either way.
What indentation should I use?
Two spaces is the most common convention for JSON and matches what most formatters and linters expect. Four spaces and tabs are both readable; consistency within a project matters more than the choice.
Can it handle very large files?
Files of a few megabytes format fine. Very large documents may take a moment or strain browser memory, since everything is processed on your device.
Why do my large numbers change?
JavaScript represents integers exactly only up to 2^53 − 1. Larger IDs lose precision when parsed, which is why APIs commonly send 64-bit identifiers as strings.
Does formatting change my data?
No. Only whitespace changes. Key order is preserved, and every value stays exactly as it was.
100% private. Files are processed on your device and never uploaded.
Instant results. No upload queue. Processing time depends on your device.
Free forever. No signup, no watermark, no paid tier.
Works everywhere. Use a modern browser on your phone or computer.
Related tools
JSON Formatter is one of all the free tools on ToolNest. No account or subscription needed — anywhere in the world.