JSON Formatter & Validator
Paste JSON to format, validate or minify it. Errors are reported with line and column.
What this JSON formatter does
This tool takes any JSON text and either pretty-prints it with consistent indentation, compresses it into a single minified line, or simply checks whether it is valid. When the input is not valid JSON, the validator points to the exact line and column where parsing failed and shows the surrounding characters, so you can fix a missing comma or an unquoted key in seconds instead of scanning a wall of text.
Everything happens locally in your browser using the JavaScript engine's native JSON parser. The text you paste is never sent to a server, which makes it safe to use with API responses, configuration files, logs or any data that contains tokens, credentials or personal information.
How to use it
Paste or type your JSON into the input box. Formatting runs automatically as you type. Choose an indentation of 2 spaces, 4 spaces or tabs, and optionally enable Sort keys to order object keys alphabetically at every nesting level, which makes two documents easy to compare with a diff tool. Click Minify to strip all whitespace when you need the smallest possible payload for an HTTP request or an environment variable. Use Copy to put the result on your clipboard or Download to save it as a .json file.
The status bar shows the size in bytes, the number of object keys and the maximum nesting depth, which is a quick way to sanity-check a large document before sending it somewhere.
Common JSON mistakes this validator catches
Trailing commas after the last item in an array or object are not allowed in JSON even though most programming languages accept them. Single quotes around strings or keys are invalid: JSON requires double quotes. Comments are not part of the JSON specification, so a // or /* */ block will fail. Unquoted keys such as {name: "x"} are JavaScript object literals, not JSON. Special values like NaN, Infinity and undefined do not exist in JSON. Each of these produces a clear error with a position you can jump to.
Background: where JSON came from
JSON (JavaScript Object Notation) was specified by Douglas Crockford in the early 2000s as a lightweight alternative to XML, using the object-literal syntax that JavaScript already had. It was standardised as RFC 4627 in 2006, then as ECMA-404 and RFC 8259 (2017), which is the current definition: six value types (object, array, string, number, true/false, null), UTF-8 as the interchange encoding, and no comments. Its rise tracked the rise of browser-side applications: a format the browser could parse natively with JSON.parse beat anything that needed a separate parser.
Where it is used
Nearly every web API returns JSON, which is why the first thing you do with an unfamiliar response is paste it into a formatter to see its shape. Configuration files (package.json, tsconfig.json, VS Code settings), infrastructure definitions (CloudFormation, Terraform state), NoSQL databases (MongoDB documents, PostgreSQL jsonb columns), log pipelines (one JSON object per line in ndjson) and the payload of a JWT token are all JSON; JSON also travels inside URL query parameters, where it must be percent-encoded first. Related formats extend it: JSON5 and JSONC add comments and trailing commas for config files, JSON Schema describes the expected structure, and JSON Lines streams many documents in one file — all of which this validator will reject as strict JSON, by design.
Frequently asked questions
Is my JSON uploaded anywhere?
No. The formatter runs entirely in your browser. You can disconnect from the internet after the page loads and it will keep working.
What is the difference between formatting and minifying?
Formatting (beautifying) adds line breaks and indentation so humans can read the structure. Minifying removes all unnecessary whitespace so the data is as small as possible for machines. Both produce semantically identical JSON.
Why does the tool say my JSON is invalid when it works in JavaScript?
JavaScript object literals are more permissive than JSON. Single quotes, unquoted keys, trailing commas and comments are all fine in JavaScript code but forbidden by the JSON standard (RFC 8259).
Is there a size limit?
There is no hard limit. Documents of several megabytes format instantly on a modern device; very large files are limited only by your browser's memory.
Does sorting keys change the meaning of the data?
No. JSON objects are unordered by specification, so reordering keys produces an equivalent document. Array order is always preserved because arrays are ordered.