JSON Formatter
Beautify, minify and validate JSON, with errors pinpointed to the line.
Runs in your browser — nothing is uploaded
Result
Valid JSON · 155 B → 208 B
How to use JSON Formatter
- 1
Paste your JSON into the JSON input box.
- 2
Choose Beautify with 2 spaces, 4 spaces or Tab, or choose Minify to remove all whitespace. Tick Sort keys A→Z for a stable key order.
- 3
If the JSON is invalid, read the error box: it gives the line, column and a pointer to the problem.
- 4
Select Copy JSON or Download .json to take the result.
About this tool
The formatter parses your input with the browser's own JSON parser, so anything it accepts is valid JSON by the official specification (RFC 8259). It then prints it again with your chosen indent, or with no whitespace at all for minified output. The sizes before and after are shown, which is useful when trimming an API payload.
When parsing fails, a second strict checker walks through the text to find exactly where it breaks and explains why in plain words: a trailing comma, a property name in single quotes or without quotes, a missing comma between items, a line break inside a string, a number with a leading zero. Those are the mistakes that usually creep in when JSON is written by hand or copied from JavaScript code.
Be aware of two limits of JSON in JavaScript. Numbers larger than 9,007,199,254,740,991 (2⁵³ − 1) lose precision when parsed, so long numeric IDs can change in the output; keep them as strings if exactness matters. If an object repeats a key, only the last value is kept. Sort keys orders object keys alphabetically at every level but leaves arrays in their original order.
Your JSON is processed only in your browser. It is not uploaded or logged, so it is safe to format API responses that contain tokens or personal data.
Questions people ask
How do I fix “Unexpected token” in JSON?
Paste the JSON here and read the error box, which shows the line and column of the first problem. The usual causes are a trailing comma, single quotes or an unquoted property name.
Are trailing commas allowed in JSON?
No. Standard JSON does not allow a comma after the last item in an object or array, although JavaScript itself does.
What is the difference between beautify and minify?
Beautify adds line breaks and indentation so people can read the JSON. Minify removes all optional whitespace to make the file as small as possible.
Does it support comments or JSON5?
No. It validates strict JSON, where comments, single quotes and unquoted keys are errors, so it will tell you where they are.
Is my JSON sent to a server?
No. Parsing and formatting happen entirely in your browser.
Related tools
- Base64 Encode & DecodeEncode and decode Base64 text, or turn any file into a data URL.
- JWT DecoderPaste a JWT to read its header, payload and expiry time.
- Text ComparePaste two versions of a text and see exactly what was added and removed.
- URL Encode & DecodePercent-encode text for a URL, or decode an encoded URL back to text.
- Hash GeneratorCalculate MD5 and SHA hashes of text or a file, and check a checksum.
- Regex TesterWrite a regular expression and see every match and group highlighted live.