How to format JSON
- Paste your JSON into the input box. It’s validated instantly.
- Choose indentation — 2 spaces, 4 spaces or tabs — and whether to sort keys alphabetically.
- Click Format / Beautify for readable output, or Minify for the most compact version.
- Copy the result or download it as a
.jsonfile.
Validate JSON instantly
As soon as you paste, the tool tells you whether the input is valid JSON. If not, it shows the error message, the line and column of the problem, and the offending line with a ^ marker under the exact character. The most common errors are:
| Error | Example | Fix |
|---|---|---|
| Trailing comma | [1, 2, 3,] |
Remove the last comma |
| Single quotes | {'name': 'Ada'} |
Use double quotes: "name" |
| Unquoted keys | {name: "Ada"} |
Quote every key |
| Comments | // note |
Remove comments |
| Missing comma | {"a": 1 "b": 2} |
Add a comma between items |
| Special values | NaN, undefined |
Use null or a number |
Note that the reported position is where the parser noticed a problem — the actual mistake is often just before it, such as a missing comma on the previous line.
Beautify vs minify
Beautified JSON has line breaks and indentation, making nested structures easy to read and review. It’s ideal for debugging API responses, reading configuration files and writing documentation.
Minified JSON removes all unnecessary whitespace. It’s the smallest possible representation of the same data, which is useful for sending over a network, embedding in code or storing in a database. The output panel shows the size in bytes so you can compare.
Sorting keys
With Sort keys A–Z enabled, every object’s keys are ordered alphabetically, at every level of nesting. That makes it much easier to:
- Compare two JSON documents line by line
- Spot missing or extra fields
- Keep configuration files consistent in version control
Arrays keep their original order, because in arrays the order is part of the data.
Why a local formatter matters
JSON often contains sensitive information: API keys, access tokens, customer records, internal configuration. Many online formatters send what you paste to their servers. This one parses and formats everything inside your browser — nothing is transmitted or logged, and it keeps working without a connection once the page is loaded.
JSON basics
JSON (JavaScript Object Notation) is the most common format for exchanging data between web services. It has only a few building blocks:
| Type | Example |
|---|---|
| Object | {"name": "Ada", "age": 36} |
| Array | ["red", "green", "blue"] |
| String | "hello" (always double quotes) |
| Number | 42, 3.14, -1e6 |
| Boolean | true, false |
| Null | null |
Objects and arrays can be nested inside each other to any depth. Anything outside these rules — comments, trailing commas, single quotes, undefined — makes the document invalid JSON, even if JavaScript itself would accept it.
Reading API responses
When debugging an API, copy the response body from your browser’s developer tools (Network tab → Response) or from a terminal, paste it here and click Format. Nested data becomes readable at a glance, and Sort keys makes it easy to compare two responses side by side. Because the formatter runs locally, you can safely paste responses that include session tokens or personal data, which you shouldn’t share with an online service that stores input. Clear the box when you’re done if you’re on a shared computer.
Tips
- Pasting a JavaScript object rather than JSON? Keys must be in double quotes and single-quoted strings aren’t allowed — fix those first.
- Working with Base64-encoded JSON, such as the payload of a token? Decode it with the Base64 decoder first, then format it here.
- For very large files (several megabytes), formatting still works, but the browser may take a moment to display the result.