JSON Formatter pretty-prints JSON with clean indentation, checks that it is valid, minifies it for production and repairs common mistakes such as trailing commas and single quotes. Invalid JSON shows the exact line and column of the error. A collapsible tree view lets you explore large API responses. Everything runs in your browser.
How to format JSON
- Paste JSON into the box, or click Open file to load a .json file.
- Choose the Indent: 2 spaces, 4 spaces or Tab. Tick Sort keys A–Z if you want the keys in alphabetical order.
- Click Format, or press Ctrl+Enter (Cmd+Enter on a Mac).
- Switch to Tree view to fold and unfold objects and arrays.
- Click Copy result or Download .json.
What each button does
| Button | What it does |
|---|---|
| Format | Pretty-prints the JSON with the chosen indent |
| Minify | Removes every space and line break, for the smallest size |
| Validate | Checks the JSON and points to the first error |
| Repair | Fixes common almost-JSON mistakes, then formats |
| Tree view | Shows the data as a collapsible tree |
Finding errors
JSON is strict. A single missing comma or an extra one at the end of a list makes the whole document invalid, and an API or a config loader will refuse it. Validate reports the first problem with its line and column and moves the cursor to that spot in the box. Fix it and validate again until the JSON is valid.
Common causes:
- Trailing comma after the last item:
[1, 2, 3,] - Single quotes instead of double quotes:
{'name': 'Ann'} - Unquoted keys:
{name: "Ann"} - Comments with
//or/* */, which JSON does not allow - Python values such as
True,FalseandNone - A missing comma between two items or two keys
Repair almost-JSON
Data copied from JavaScript code, a Python print-out or a config file with comments is often close to JSON but not quite. Repair fixes all of the mistakes above in one go: it strips comments and trailing commas, converts single quotes, quotes bare keys, and changes True, False and None into their JSON spellings. NaN, Infinity and undefined have no JSON equivalent and become null. Look over the result before you use it, since a repair has to guess what was meant.
Minify for production
Minify removes all whitespace. The result is a single line, often a third smaller or more for deeply indented files, which saves bandwidth in API payloads and keeps config strings short. Format it again whenever you need to read it.
Tree view
Large API responses are hard to read even when formatted. Tree view shows each object and array as a node you can fold and unfold, with the number of items in each. Open only the branch you care about and leave the rest closed.
Tips
- Compare two JSON files: format both with the same indent and sorted keys, then paste them into Text Compare to see what changed.
- Base64 inside JSON: decode embedded Base64 strings with Base64 Encode and Decode.
- Spreadsheet data: to turn a CSV file into a spreadsheet, use CSV to Excel.
Private by design
Your JSON is processed on your own device and never uploaded. That matters for API responses, tokens and customer data. See how it works.