JSON Formatter & Validator
Format, validate and minify JSON with helpful error messages.
Input
Output
How to use JSON Formatter & Validator
Paste your JSON
Drop a file into the editor or paste the JSON directly. Nothing is uploaded.
Check the result
The output pane shows the formatted document, or a clear explanation of what is wrong and where.
Format, minify or sort
Use the toolbar to pretty-print the document, strip the whitespace, or sort every key.
Copy or download
Copy the result to the clipboard or save it as a .json file.
Frequently asked questions
What is the difference between JSON and JavaScript object literals?
A JavaScript object literal allows comments, unquoted keys, single quotes and trailing commas. JSON allows none of those. That is why code that looks like JSON often fails to parse.
Why does my JSON fail with "Unexpected token"?
Almost always because of a trailing comma, a missing comma between two values, or a string value that contains an unescaped quote. Check the reported line and the line before it.
Is my JSON sent to a server?
No. Parsing, formatting and validation all happen inside your browser using the built-in JSON parser.
Can I format a very large JSON file?
Yes. The tool handles multi-megabyte documents comfortably, although re-rendering the output on every keystroke is the slowest part.
What does the size change figure mean?
It is the difference in characters between the input and the formatted output. Formatting always makes the file larger because it adds indentation.
About JSON Formatter & Validator
The JSON Formatter validates and pretty-prints any JSON document, explains exactly what is wrong when it cannot be parsed, and shows you the structure of the data at a glance. It also minifies JSON for production payloads and sorts keys so that two documents can be compared line by line.
Why a formatter beats a validator
A validator tells you that something is wrong. A formatter tells you where. Pretty-printing a document with two-space indentation exposes its structure, and structure makes mistakes obvious: a missing comma between two long blocks is invisible in a single-line blob and obvious once the document is indented. Because the tool also reports the line and column of the parse error, you can jump straight to the offending character instead of scanning the whole document by eye.
The mistakes that account for most broken JSON
In practice, almost every JSON error is one of five things. A trailing comma after the last item in an object or array is the most common by a wide margin, and it is a legal habit in JavaScript arrays but illegal in JSON. Unescaped quotes inside a string value are the second most common, for example a sentence containing double quotes that is itself wrapped in double quotes. Single quotes instead of double quotes come third, followed by comments — JSON has no comment syntax at all — and finally a missing or doubled comma between values.
Why the error position is not always the culprit
When the parser reports an error at a particular line and column, that is where it gave up, not necessarily where the mistake is. An unclosed string, for example, makes everything after the opening quote look wrong, so the reported position can be far from the real problem. A useful technique is to scan backwards from the reported position: the actual fault is usually a few characters earlier. This tool shows the position so you can do exactly that.
Formatting, minifying and sorting
Formatting pretty-prints the document with your chosen indentation. Minifying strips all unnecessary whitespace, which is what you want before embedding a payload in a script tag or sending it over a network. Sorting keys recursively reorders every object alphabetically, which is genuinely useful: it turns two documents that differ only in key order into a pair that can be compared with a plain text diff, and it makes generated configuration files stable across runs.
Use JSON Formatter & Validator on your site
This tool runs free and private in the browser. Paste it anywhere — blog posts, documentation, team wikis — and your visitors will use it without leaving your site. The embed includes a small "Made with The Tools Today" credit link.
Related tools
Base64 Encode / Decode
Encode and decode Base64 for text and files with UTF-8 support.
Open toolRegex Tester
Test regular expressions with flags, matches, groups, and replace preview.
Open toolURL Encode / Decode
Encode or decode URLs and query parameters safely in your browser.
Open toolJWT Decoder
Decode JWT header and payload claims locally (signature not verified).
Open tool