JSON Formatter
Beautify, minify and validate JSON with exact error locations.
What is a JSON formatter?
JSON (JavaScript Object Notation) is the most common format for sending data between web services, apps and configuration files. Machines often produce it as one long line with no spaces, which is efficient to send but almost impossible for a person to read. A JSON formatter adds line breaks and indentation so the structure of objects and arrays becomes clear. The same tool can also do the opposite and minify JSON, removing every unnecessary space to make it as small as possible.
This formatter also works as a validator. If the JSON is broken, it tells you what went wrong and gives the exact line and column, then places the cursor at that spot in the input box so you can fix it quickly.
How to format JSON
- Paste your JSON into the input box, or open a
.jsonfile from your device. - Choose an indentation style: 2 spaces, 4 spaces, 1 space or tabs.
- Tick Sort keys A to Z if you want object properties in alphabetical order.
- Click Format / Beautify, Minify or Validate.
- Copy the result or download it as a
.jsonfile.
Features
- Clear error messages such as “Trailing comma before ] is not allowed” or “Strings must use double quotes”, with line and column numbers.
- Recursive key sorting, which makes two JSON documents easier to compare.
- Size statistics showing output size, line count, total keys and nesting depth.
- Private: parsing happens in your browser, so API responses that contain personal data stay on your device.
Common JSON mistakes
Most invalid JSON comes from a handful of habits carried over from JavaScript. JSON does not allow trailing commas after the last item, single quoted strings, comments, unquoted property names or values such as undefined and NaN. Line breaks inside strings must be written as \n. Numbers cannot have leading zeros. If the validator reports an error, look at the character just before the reported column, because the real mistake is often a missing comma or quote on the previous item.
When to beautify and when to minify
Beautify JSON when you are reading, debugging or reviewing it, for example when inspecting an API response or editing a configuration file. Minify JSON when it will be stored or sent over a network, such as data embedded in a web page or a payload for a request. Minified JSON is often 20 to 40 percent smaller than formatted JSON, depending on how deeply it is nested.
Tips
Use the sort keys option before comparing two JSON files in a diff tool, so differences in property order do not hide real changes. Very large numbers beyond about 15 significant digits lose precision in JavaScript, so treat long IDs as strings in your own APIs.
Frequently asked questions
Is my JSON uploaded to a server?
No. The formatter uses your browser to parse and format the JSON. Nothing you paste or open is sent anywhere.
Why does the validator say my JSON is invalid when it works in JavaScript?
JavaScript object literals allow things that JSON does not, such as comments, single quotes, unquoted keys and trailing commas. The error message tells you which rule was broken and where.
Can it handle large files?
Yes. Files up to 50 MB can be opened, and documents of a few megabytes format almost instantly on a modern device.
Does sorting keys change my data?
Only the order of properties inside objects changes. Values stay the same and the order of items in arrays is kept.