How to format JSON
- Paste your JSON into the Input box — for example an API response, a configuration file or a log entry.
- Press Format / Beautify to indent it neatly, or Minify to remove all unnecessary whitespace.
- If the JSON is invalid, the tool tells you what is wrong and where — the line and column — and selects the problem in the input box.
- Copy the result or download it as a
.jsonfile.
What is JSON?
JSON (JavaScript Object Notation) is a lightweight text format for structured data. It is the standard language of web APIs and is used in configuration files, databases and mobile apps. JSON is built from two structures: objects — key/value pairs inside curly braces {} — and arrays — ordered lists inside square brackets []. Values can be strings, numbers, true, false, null, objects or arrays.
The most common JSON errors
| Error | Wrong | Right |
|---|---|---|
| Trailing comma | {"a": 1,} | {"a": 1} |
| Single quotes | {'a': 'b'} | {"a": "b"} |
| Unquoted keys | {a: 1} | {"a": 1} |
| Comments | {"a": 1 // note} | Remove comments — JSON does not allow them |
| Missing comma | {"a": 1 "b": 2} | {"a": 1, "b": 2} |
| Special values | NaN, undefined | Use null or a string |
Many of these are valid in JavaScript, which is why JSON copied from code often fails to parse. The validator follows the official JSON standard (RFC 8259) used by every API.
Beautify vs. minify
Beautified JSON is indented with one value per line, which makes it easy to read, review and compare. Minified JSON removes every unnecessary space and line break, producing the smallest possible file — useful for sending data over a network or storing it efficiently. Both contain exactly the same data.
Sorting keys
Turn on Sort keys A–Z to order every object’s keys alphabetically, at every level. This makes it much easier to compare two JSON documents — format both with sorted keys and paste them into our Text Compare tool to see exactly what changed.
Is it safe to paste sensitive JSON?
Yes. Many online formatters send your data to a server. This tool uses your browser’s built-in JSON.parse and JSON.stringify, so API keys, tokens and customer records never leave your computer.
Frequently asked questions
How do I validate JSON?
Paste it and press Format. If the JSON is valid, it is formatted and a success message appears. If not, you will see the error message with its line and column.
Why does my JSON have an “Unexpected token” error?
Usually because of a trailing comma, single quotes, an unquoted key or a comment. Check the line and column shown, and the character just before it.
Can it handle large JSON files?
Yes. Files of several megabytes format in a moment on a modern computer, because nothing is uploaded.
Does sorting keys change my data?
No. Key order has no meaning in JSON objects, so sorting only changes how it looks. Array order is never changed.
Is my JSON sent to a server?
No. Everything is processed locally in your browser.