JSON Formatter
Beautify, minify and validate JSON with precise error positions.
What this JSON formatter does
Paste raw JSON and it is parsed, checked and re-printed with consistent indentation. If the document is invalid, you get the exact line and column where parsing stopped instead of a vague “unexpected token”, plus the offending snippet — usually a trailing comma, a single quote, or an unescaped newline inside a string.
The same input can be minified to the smallest valid form for shipping in a config file or a URL, and object keys can be sorted alphabetically at every level, which makes two API responses genuinely diffable.
How to use it
- Paste or type JSON into the left pane. Formatting runs as you type.
- Pick 2 spaces, 4 spaces or Tab to match your project's style.
- Press Minify for a single-line version, or Sort keys before comparing two payloads.
- Copy the result, or download it as a
.jsonfile.
Keyboard: Ctrl/⌘ + Enter formats, Ctrl/⌘ + Shift + C copies the output.
Common JSON errors, translated
- Unexpected token
}— usually a trailing comma after the last item. JSON, unlike JavaScript, forbids them. - Unexpected token
'— JSON strings and keys must use double quotes. - Unexpected end of input — a bracket or brace was never closed, often because the payload was truncated.
- Unexpected token
N—NaN,Infinityandundefinedare not valid JSON values. - Bad control character — a real newline or tab inside a string. It must be written as
\nor\t.
Frequently asked questions
Is my JSON uploaded anywhere?
No. Parsing and formatting happen in your browser using the built-in JSON engine. Nothing is sent over the network, which is why this tool is safe to use with production payloads, access tokens and customer data.
How large a file can it handle?
Documents of a few megabytes format in well under a second on a normal laptop. Very large files — tens of megabytes — may make the browser pause while the text area redraws, since the limit is rendering rather than parsing.
Does it support JSON with comments or trailing commas?
Not by design. Those belong to JSON5 and JSONC, not to the JSON specification, and silently accepting them would let invalid files through to systems that reject them. The error message will point at the exact character so you can remove it.
Why does sorting keys change my file?
JSON objects are unordered by specification, so sorting is safe for any correct parser. It is a common preprocessing step before diffing two API responses, because it removes noise caused purely by key ordering.
Are big numbers preserved exactly?
Numbers are parsed as IEEE-754 doubles, so integers beyond 2^53 (such as Twitter-style snowflake IDs) can lose precision. If that matters, keep those values as strings in the source system.