What is the JSON Formatter?
A JSON formatter (also called a JSON beautifier or pretty printer) takes compact or messy JSON and re-indents it so the structure is easy to read. This tool also validates your JSON against the standard (RFC 8259). If something is wrong, such as a trailing comma, a single-quoted string or a missing bracket, it shows the error message with the line and column so you can fix it quickly.
You can also minify JSON, which removes all unnecessary whitespace for smaller API payloads and config files. Turn on Sort keys to sort object keys alphabetically at every level. Sorted keys make two JSON documents much easier to compare.
Parsing happens with your browser's built-in JSON.parse, so API responses, tokens and customer data you paste here never leave your computer.
How to use the JSON Formatter
- Paste your JSON into the Input JSON box, or click Sample to try an example.
- Choose the indentation (2 spaces, 4 spaces or tabs) and, if you want, tick Sort keys.
- Click Format to beautify, Minify to compress, or Validate to only check the syntax. Ctrl+Enter also formats.
- If the JSON is invalid, read the red message: it names the problem and its line and column.
- Copy the result or download it as a
.jsonfile.
Common JSON errors and how to fix them
| Error | Example | Fix |
|---|---|---|
| Trailing comma | [1, 2, ] | Remove the comma after the last item. |
| Single quotes | {'a': 1} | JSON strings and keys must use double quotes: {"a": 1}. |
| Unquoted keys | {a: 1} | Quote every key: {"a": 1}. |
| Comments | // note | Standard JSON has no comments. Remove them. |
| Special values | NaN, undefined | Use null or a string instead. |
Frequently asked questions
Is my JSON sent to a server?
No. Formatting and validation run in your browser with JavaScript. Nothing you paste is uploaded or saved.
What is the difference between formatting and minifying JSON?
Formatting adds line breaks and indentation so people can read it. Minifying removes all optional whitespace so the file is as small as possible for machines. Both contain exactly the same data.
Why does my JSON with comments fail to validate?
The JSON standard does not allow comments, trailing commas or single quotes. Formats such as JSON5 and JSONC allow them, but most JSON parsers, including the one in browsers, reject them.
Can it handle large JSON files?
Yes. Files of several megabytes format in well under a second on a modern computer. Very large files (100 MB or more) depend on your device's memory.
Does sorting keys change my data?
No. Key order has no meaning in a JSON object, so sorting keys only changes how the data is displayed. Array order is never changed.