JSON Formatter & Validator
Paste raw or minified JSON to validate it and pretty-print it with 2 or 4 spaces of indentation. Switch to minify to compact it onto one line. If the JSON is not valid, the tool names the first problem in plain words with its line and column, for example a trailing comma, a single-quoted string or a missing comma. Only the white space changes: numbers, strings and the order of keys stay exactly as you wrote them. Everything runs locally in your browser.
Related Tools
[7 suggestions]Base64 Encoder / Decoder
Easily encode plain text to Base64 format or decode Base64 back to readable text.
Developer & WebURL Encoder / Decoder
Encode URI components or decode percent-encoded URLs safely and reliably.
Developer & WebRegex Tester
Test regular expressions against a string, highlight matches, and inspect capture groups.
Developer & WebSQL Formatter and Beautifier
Format and beautify SQL queries with one clause per line, keyword case and indent options, for PostgreSQL, MySQL, SQLite, SQL Server and more.
Developer & WebJSON to TypeScript Converter
Paste JSON and get TypeScript interfaces or types, with optional keys, unions and nested types worked out from your sample.
Developer & WebXML Formatter and Validator
Format, minify and validate XML. Errors show the line and column, and the text inside your elements is never changed.
Developer & WebCode to Image Generator
Turn a code snippet into a shareable image with syntax colors, a window bar, line numbers and a gradient backdrop, as a PNG, JPEG, WebP or SVG.
Developer & WebGuides for the JSON Formatter
- How to Format XML and Fix Well-Formedness Errors
Learn how to format XML and fix well-formedness errors: unclosed tags, nbsp, bad attributes. Tested against libxml2 on 42,145 documents. (November 15, 2026)
- How to Convert JSON to TypeScript Interfaces
Learn how to convert JSON to TypeScript interfaces: nested objects, optional keys, unions and arrays. Checked with the compiler on 2,000 documents. (November 15, 2026)
- How to Format SQL: Style Rules, Dialects and Safe Formatting
Learn how to format SQL: clause layout, keyword case and why the dialect matters. Tested on 1,434 queries against SQLite bytecode, with no change in meaning. (November 13, 2026)
- How to Convert YAML to JSON: Types, Anchors and Multiple Documents
Learn how to convert YAML to JSON in a browser, Python, JavaScript or yq, and what changes on the way: yes and no, anchors, comments and big numbers. (November 8, 2026)
About the JSON Formatter & Validator
The JSON Formatter checks your text against the JSON grammar (RFC 8259) and re-indents it by changing only the white space between tokens. A common shortcut is JSON.parse() followed by JSON.stringify(), but that rewrites the data: a number such as 12345678901234567890 becomes 12345678901234567000, 1.50 becomes 1.5, keys that look like integers move to the front, and when a key appears twice only the last value survives. This tool leaves all of that alone, and it warns you about repeated keys and about numbers a JavaScript program would round. Its validator accepts exactly the text that JSON.parse() accepts (we compared them on 40,000 damaged documents), but the message does not depend on your browser: it explains what is wrong, such as a trailing comma, single quotes, an unquoted key, a comment, NaN, a leading zero or a line break inside a string, and gives the line and column. Minify mode removes every unnecessary space and line break, which is useful before embedding JSON in an API request or an environment variable.
Why does my JSON fail to parse?▾
JSON has strict rules: property names and strings need double quotes, a comma cannot follow the last item, and comments, NaN and undefined are not allowed. The tool shows the first problem with its line and column and says how to fix it.
What is the difference between pretty-print and minify?▾
Pretty-print adds line breaks and 2 or 4 spaces of indentation so the structure is easy to read. Minify removes all unnecessary white space to produce the smallest valid text, which is useful for API requests and storage. Neither changes the data.
Does this support JSON with comments (JSONC)?▾
No. Standard JSON does not allow comments, and the tool will point at the first comment it finds. If you have JSONC, as in tsconfig.json, remove the comments before pasting.
Does formatting change my numbers or key order?▾
No. Many formatters parse the JSON and write it back, which rounds large numbers and reorders keys that look like integers. This tool only changes white space, so 12345678901234567890 and 1.50 stay as written.
What happens if a key appears twice?▾
The text is valid JSON, and the tool keeps both keys and shows a warning. Most programs keep only the last value, so the first one is silently lost when the data is read.