How to use the JSON formatter
- Paste JSON into the left panel, or open a
.jsonfile. - Click Format to pretty-print with 2 or 4 spaces or tabs, or Minify to strip all whitespace.
- Turn on Sort keys for deterministic, diff-friendly output.
- Copy the result or download it as a file.
Common JSON errors
| Error | Typical cause |
|---|---|
Unexpected token ' | Single quotes. JSON strings and keys must use double quotes. |
| Expected double-quoted property name | Trailing comma, or an unquoted key like {name: 1}. |
| Unexpected end of JSON input | Missing closing } or ], or truncated copy-paste. |
| Bad control character in string | A raw newline or tab inside a string — escape it as \n / \t. |
Unexpected token / | Comments. Standard JSON has no comments (use JSONC/JSON5 tools for those). |
Escape and unescape
Escape converts arbitrary text (for example a JSON document) into a single JSON string literal — handy
when you need to embed JSON inside another JSON field or an environment variable. Unescape reverses it.
Frequently asked questions
Is my JSON sent to a server?
No. Parsing and formatting happen with JavaScript inside your browser tab. You can disconnect from the internet after the page loads and the formatter still works.
How do I find where my JSON is broken?
Click Format or Validate. If the JSON is invalid, the tool shows the error message together with the line and column and a snippet of the surrounding lines with a caret pointing at the problem.
Why is a trailing comma invalid in JSON?
The JSON specification (RFC 8259) does not allow trailing commas after the last element of an object or array, even though JavaScript does. Remove the comma before the closing } or ].
What does “Sort keys” do?
It recursively orders object keys alphabetically. This makes two JSON documents easier to compare in a diff and gives stable output for config files.
Is there a size limit?
Only your browser memory. Files of several megabytes format instantly on a modern machine.