JSON formatter and validator
Paste JSON or open a .json file to pretty-print it with 2 spaces, 4 spaces or tabs, minify it into a single line, or sort object keys alphabetically. If the JSON is invalid, the validator shows the exact line and column of the problem with a pointer to the character, so you can fix it quickly. Your data is processed locally and never uploaded.
Output
Indentation
How to use the JSON Formatter
- 1
Add your JSON
Paste it into the input box or open a .json file from your device.
- 2
Choose the output
Select Pretty with your preferred indentation, or Minify for the smallest size. Optionally sort keys.
- 3
Fix any errors
If the JSON is invalid, read the line and column shown and the pointer under the faulty character.
- 4
Copy or download
Copy the formatted result or download it as a .json file.
How validation works
Validation follows the JSON standard (RFC 8259). Strings must use double quotes, trailing commas and comments are not allowed, and numbers cannot have leading zeros.
When parsing fails, a small standards-based scanner finds the first character that breaks the rules and reports its line and column, so the error position is the same in every browser.
Sorting keys reorders object properties alphabetically at every level but never changes the order of items in arrays, because array order carries meaning.
When to use it
- Read API responses and log entries that arrive as one long line.
- Find the missing comma or quote that breaks a configuration file.
- Minify JSON before embedding it in code or sending it over the network.
- Sort keys so two JSON files can be compared with a diff tool.
Limits
- Files up to 10 MB can be opened; very large documents may be slow on older phones.
- Strict JSON only: JSON5, comments and JavaScript object syntax are reported as errors.
Privacy
Formatting and validation happen entirely in your browser. Your JSON is never uploaded, which makes the tool safe for tokens and private data.
Frequently asked questions
Why is my JSON invalid when it works in JavaScript?
JavaScript object literals allow single quotes, unquoted keys, comments and trailing commas. JSON allows none of these; keys and strings must use double quotes.
What is the difference between pretty and minified JSON?
Pretty JSON adds line breaks and indentation for humans to read. Minified JSON removes all unnecessary whitespace to make the data as small as possible.
Does sorting keys change my data?
No. Object keys have no meaningful order in JSON, so sorting only changes presentation. Array items are never reordered.
Is it safe to paste API keys or personal data?
Yes. The tool runs entirely in your browser and sends nothing to any server.
Can it handle Sinhala, Tamil or emoji in strings?
Yes. All Unicode text is preserved exactly, including in the formatted and minified output.
Why does a BOM at the start not cause an error?
Some editors add an invisible byte-order mark to files. The tool removes it automatically before parsing.
Related tools
People also use
- JWT Generator & SignerCreate and sign JSON Web Tokens with HMAC, RSA or ECDSA keys, entirely in your browser.
- Base64 Encoder & DecoderEncode and decode Base64 and Base64url, text or files.
- URL Encoder & DecoderPercent-encode or decode URLs and see their query parameters.
- CSV to JSON ConverterConvert CSV ⇄ JSON with correct quoting, types and nested data.
Last updated November 17, 2026 · How we build and test our tools