JSON Formatter

Paste JSON to pretty-print, minify and validate it - with the exact line and column of any error. Nothing leaves your browser.

Format, validate and minify JSON

JSON (JavaScript Object Notation) is the format nearly every web API speaks in, but a raw response arrives as one dense, unreadable line. Paste it above and hit Format to get clean, indented output you can actually scan. Prefer a compact payload for a request body or a config value? Minify strips every optional space and newline while keeping the data identical.

Every time you type, the tool parses your input with the browser's own JSON engine. If it is valid you get a green tick and a count of the top-level keys; if not, you get the precise line and column of the first problem, plus a caret pointing at the offending character. That is usually far faster than squinting at a wall of brackets.

Reading a JSON error

Most invalid JSON fails for one of a handful of reasons. Keys and strings must use double quotes, never single quotes or none at all. There is no trailing comma allowed after the last element of an array or object. Every string, array and object must be properly closed. And special characters inside strings - quotes, backslashes, newlines - have to be escaped. When the error reads Unexpected token } in JSON at position 42, position 42 is the character index the parser choked on, which the caret preview above turns into a visible spot.

Two-space, four-space or tabs

Indentation is purely cosmetic - all three produce byte-for-byte equivalent data. Two spaces is the most common default (it is what package.json and most style guides use), four spaces reads well for deeply nested structures, and tabs let each viewer set their own width. Pick whatever matches the file you are pasting back into.

Working with other developer formats? Try the Base64 encoder for encoding payloads, the JWT decoder to inspect tokens whose payload is itself JSON, or the URL encoder when you need to pass JSON in a query string.

Frequently asked questions

What does a JSON formatter do?
It takes JSON text and re-prints it with consistent indentation and line breaks so it is easy to read, or strips all whitespace to minify it. It also validates the JSON and points to the exact spot any syntax error occurs.
Why does my JSON say "Unexpected token"?
That error means a character was found where the parser did not expect one. The usual causes are a trailing comma after the last item, single quotes instead of double quotes, unquoted keys, or a missing comma between items. The error line and column above show you exactly where to look.
Is my JSON sent to a server?
No. All parsing, formatting and minifying happens in your browser with JavaScript. Nothing you paste is uploaded, so it is safe to use with private API responses, config files and tokens.
What is the difference between formatting and minifying?
Formatting (pretty-printing) adds indentation and newlines for humans to read. Minifying removes every unnecessary space and newline to make the payload as small as possible for transport - the two are lossless opposites of each other.
Does JSON allow comments or trailing commas?
No. Standard JSON has no comments and does not allow a trailing comma after the last array item or object property. If you need those, you are using a superset like JSON5 or JSONC, which this validator will reject.