English
How to use the JSON formatter
This JSON formatter checks your JSON and pretty-prints it the moment you paste it, so you can read an API response, fix a config file or tidy test data without installing anything.
- Paste JSON into the input box, or press Load sample to try it.
- Pick an indentation: 2 spaces (common in JavaScript projects), 4 spaces (common in Python and Java) or Tab.
- Choose Format for readable output or Minify for the smallest possible text.
- Press Copy, or Download .json to save the result as a file.
If the JSON is broken, the output box is replaced by an error message with the line and column number and a small excerpt with a caret (^) under the exact spot.
Common JSON errors and how to fix them
JSON looks like JavaScript but its rules are much stricter. These mistakes cause most "invalid JSON" errors:
| Invalid | Valid | Why |
|---|---|---|
| {'name': 'Ana'} | {"name": "Ana"} | Strings and keys need double quotes. |
| {name: "Ana"} | {"name": "Ana"} | Keys must be quoted. |
| [1, 2, 3,] | [1, 2, 3] | No comma after the last item. |
| {"a": 1 "b": 2} | {"a": 1, "b": 2} | Items are separated by commas. |
| {"n": 007} | {"n": 7} | No leading zeros in numbers. |
| {"ok": True} | {"ok": true} | true, false and null are lowercase. |
| // comment | (remove it) | Comments are not part of JSON. |
When the error points at a line, the real mistake is often just before it. A missing comma, for example, is only noticed when the parser reaches the next value.
How the formatter works
The tool reads your text character by character following the JSON standard (RFC 8259). As it goes, it builds the formatted output and stops at the first rule that is broken. Because it never converts values to JavaScript numbers, very large numbers such as 64-bit IDs and long decimals are kept exactly as you wrote them, and escape sequences like é are left untouched.
The figures under the output show the size of the result, the number of keys across all objects, and the deepest level of nesting. Deep nesting is fine for machines but can be a hint that a structure is harder than it needs to be.
Format or minify?
- Format when people need to read the data: debugging, code reviews, documentation, config files kept in version control.
- Minify when only machines read it: request bodies, values stored in a database or environment variable, or files served to a browser.
Here is the same object in both styles:
{
"id": 7,
"tags": [
"a",
"b"
]
}
On the web, gzip or Brotli compression already shrinks whitespace well, so minifying mostly matters for storage limits and request size rather than download speed.
Privacy and limits
Your JSON is processed only in your browser tab; nothing is uploaded or logged. Files of several megabytes work fine, though very large inputs take a moment to format on slower phones. Even so, avoid pasting live passwords or private keys into any website, including this one, when you do not need to.
Frequently asked questions
How do I format JSON online?
Paste your JSON into the input box. It is checked and pretty-printed instantly with 2 spaces; switch to 4 spaces or tabs if you prefer, then copy the result or download it as a .json file.
Why is my JSON invalid?
The most common causes are single quotes instead of double quotes, a trailing comma after the last item, a missing comma between items, comments, and unquoted keys. The error message shows the line and column of the first problem.
What does minify JSON mean?
Minifying removes all spaces and line breaks that are not inside strings. The data stays exactly the same but the file is smaller, which is useful for APIs, config values and storage.
Does JSON allow comments or trailing commas?
No. Standard JSON (RFC 8259) allows neither. Some tools accept JSONC or JSON5, which do, but a strict parser like the one in browsers and most APIs will reject them.
Is my JSON sent to a server?
No. Parsing and formatting happen entirely in your browser with JavaScript. Your data never leaves your device, so it is safe for API keys or customer data, though you should still avoid sharing secrets.