JSON Formatter
Check whether JSON is valid, see exactly what is wrong if not, and format, minify or sort it. Numbers and strings stay exactly as written.
Runs in your browser. Nothing is uploaded.
Updated
How to use JSON Formatter
- Paste JSON or open a .json file.
- Read the result: valid, or the line and reason for the error.
- Pick an indent or minify, then copy or download.
JSON Formatter at a glance
Typical use: Paste a one-line API response to read it, or fix a config file that fails with “Unexpected token”.
Files up to 10 MB are read on your device and never uploaded. Duplicate keys are kept and flagged. Nesting is limited to 1,000 levels.
When to use JSON Formatter
Paste an API response, a config file or a log line to make it readable, or open a .json file from your computer. The page tells you straight away whether the JSON is valid. If it isn’t, you get the line and column, the line itself with a marker under the problem, and what to change, in plain words.
Everything runs in your browser, so you can check JSON that contains tokens, customer data or internal settings. Files up to 10 MB are read on your device and never uploaded.
JSON Formatter examples
- Read a minified API response: paste
{"id":7,"tags":["a","b"]}and get it indented, one key per line. Choose Minify to turn it back into one line before you put it in a request. - Fix a config that won’t load:
{name: 'app', debug: True,}is JavaScript- or Python-style, not JSON. Fix common mistakes quotes the key, switches to double quotes, changes True to true, removes the trailing comma and lists each change. - Compare two exports: format both with Sort keys A–Z so properties are in the same order, then paste them into Compare Text to see real differences only.
The most common JSON errors
| Not valid | Valid JSON | Why |
|---|---|---|
| {"a": 1,} | {"a": 1} | No comma after the last item |
| {'a': 'x'} | {"a": "x"} | Only double quotes |
| {a: 1} | {"a": 1} | Property names are always quoted |
| {"a": 1 "b": 2} | {"a": 1, "b": 2} | Commas between items |
| {"ok": True} | {"ok": true} | true, false and null are lowercase |
| // comment | (remove it) | JSON has no comments |
| {"n": 007} | {"n": 7} | No leading zeros; quote codes like "007" |
| "C:\new" | "C:\\new" | A backslash must be doubled |
Prefer the terminal?
In a terminal, jq formats and checks JSON (add -S to sort keys, -c to minify):
jq . data.json
jq -S --indent 4 . data.json > sorted.json
python3 -m json.tool data.jsonjq rewrites some numbers (1e2 becomes 1E+2), keeps only the last of duplicate keys and refuses nesting deeper than 256 levels. This page keeps numbers and strings exactly as written.
References
Frequently asked questions
Is my JSON uploaded anywhere?
No. Checking, formatting and fixing all happen in your browser, and files you open are read on your device. Nothing is sent to a server.
Why does this page keep my numbers exactly, when other formatters change them?
Many formatters run JSON.parse, which turns every number into a JavaScript number: 12345678901234567890 becomes 12345678901234567000 and 1.50 becomes 1.5. This tool only changes the spaces and line breaks, and the order of keys if you sort them, so numbers and strings stay exactly as written.
What does “Fix common mistakes” change?
It removes comments and trailing commas, changes single quotes to double quotes, adds quotes around property names, adds missing commas between items, turns True, False and None into true, false and null, and turns undefined, NaN and Infinity into null. It lists every change with its line, and you can undo it. Anything else is reported, not guessed.
My file has one JSON object per line. Why is it invalid?
That format is JSON Lines (.jsonl). A JSON document holds a single value, so several objects must be wrapped in [ ] with commas between them. Check each line separately, or convert the file to an array first.
What happens to duplicate keys?
They are kept in the output and you get a warning with the line number. JSON allows them, but most programs keep only the last value, so a duplicate usually means a mistake.
How large can the JSON be?
Files up to 10 MB. Checking and formatting large JSON runs in the background, and a 10 MB file is ready in a few seconds on a typical laptop. Results over 500 KB are shown as a preview; Copy and Download always give you the whole result.