JSON Formatter and Validator
Paste JSON to check it is valid, format it for reading, minify it for sending, or sort its keys — with precise error locations.
Result
Paste JSON to validate and format it.
How to use this tool
- Paste JSON into the box. It is checked as you type.
- Choose Format (with 2 spaces, 4 spaces or tabs) or Minify, and optionally sort keys alphabetically.
- Errors show the line and column, such as a trailing comma or single quotes. Use Download .json to save the result.
How it works
The text is parsed with the browser’s standard JSON parser and re-serialised with your chosen indentation. If parsing fails, a separate strict checker walks the text to report the first problem and where it is, with a plain-English message. Key sorting is applied recursively to every object.
Example
Formatting
{"b":1,"a":[1,2]} with Sort keys becomes an indented object with "a" first and "b" second.
Finding an error
A trailing comma before } on line 3 is reported as “Invalid JSON at line 3, column 1: Trailing commas are not allowed in JSON.”
Privacy and limitations
- Your JSON is processed in your browser and never uploaded — safe for configuration files and API responses.
- JSON does not allow comments, trailing commas or single-quoted strings; these are reported as errors.
- Integers larger than 9,007,199,254,740,991 cannot be represented exactly in JavaScript and may be rounded; the tool warns you when it sees them.
Frequently asked questions
Why is my JSON invalid when it works in JavaScript?
JavaScript object literals allow unquoted keys, single quotes, comments and trailing commas. JSON allows none of these.
Does formatting change my data?
Only whitespace (and key order if you choose sorting). Values are unchanged, except very large integers as noted above.