JSON Formatter & Validator
Paste JSON to pretty-print it, find syntax errors by exact line and column, minify it for production, sort keys, or explore it as a collapsible tree.
Input Empty
Output
Formatted JSON appears here.How to format and validate JSON
Paste or open your JSON
Paste from an API response, log file or config — or open a
.jsonfile. Validation runs as you type.Fix any errors
If the JSON is invalid, you’ll see the exact line and column with the surrounding text, plus a hint for common mistakes like trailing commas or single quotes.
Format, minify or explore
Pretty-print with 2 spaces, 4 spaces or tabs, minify to a single line, sort keys alphabetically, or switch to the tree view to collapse large objects.
Common JSON syntax errors
JSON (JavaScript Object Notation, RFC 8259) is stricter than JavaScript object literals. These mistakes cause most “Unexpected token” errors:
| Mistake | Invalid | Valid |
|---|---|---|
| Trailing comma | [1, 2, 3,] | [1, 2, 3] |
| Single quotes | {'a': 1} | {"a": 1} |
| Unquoted keys | {a: 1} | {"a": 1} |
| Comments | {"a": 1 // note} | Remove comments |
| Special numbers | NaN, Infinity, 0x1F | null or a decimal number |
| Unescaped control characters | A raw tab or newline inside a string | \t, \n |
Format JSON on the command line
jq . data.json # pretty-print
jq -c . data.json # minify
python3 -m json.tool data.json # pretty-print with Python
node -e "console.log(JSON.stringify(require('./data.json'), null, 2))"Frequently asked questions
Is my JSON sent to a server?
No. Parsing, formatting and validation use your browser’s built-in JSON.parse and JSON.stringify. Your data never leaves the page, so it’s safe for API keys, tokens and private payloads.
How do I find where my JSON is invalid?
Paste it into the input. The validator reports the line and column of the first error and shows the surrounding text with a marker, so you can jump straight to the problem.
What is the difference between formatting and minifying?
Formatting (pretty-printing or beautifying) adds indentation and line breaks so humans can read it. Minifying removes all unnecessary whitespace to make the payload as small as possible for transfer or storage. Both represent exactly the same data.
Does sorting keys change my data?
No. JSON objects are unordered by specification, so sorting keys alphabetically doesn’t change meaning. It makes diffs and comparisons much easier. Array order is always preserved.
Can it handle large JSON files?
Yes. Files of several megabytes format in a fraction of a second. For very large documents, syntax colouring and the tree view are limited to keep the page responsive, but formatting, minifying and copying still work on the full data.