About the JSON Formatter & Validator
API responses and configuration files are often delivered as one long line of JSON that is impossible to read. The JSON Formatter indents it neatly, highlights the syntax and tells you exactly where any error is.
You can also minify JSON to save space, sort keys and copy or download the result. Your data is processed locally and never uploaded, which is important when working with API keys or customer data.
How to use the JSON Formatter & Validator
- Paste your JSON or load a file.
- Click format to beautify it, or minify to compress it.
- Fix any errors highlighted by the validator.
- Copy or download the formatted JSON.
Key features
- Beautify with custom indentation
- Validation with error location
- Minify and sort keys
- Syntax highlighting
Common JSON errors and how to fix them
Most invalid JSON comes from a handful of mistakes: a trailing comma after the last item in an object or array, single quotes instead of double quotes, unquoted keys, comments (which standard JSON does not allow) and values such as undefined or NaN that only exist in JavaScript. The validator reports the line and position of the first error so you can go straight to it.
Formatting does not change your data. Beautifying adds indentation and line breaks for reading, minifying removes them for sending over the network, and sorting keys makes two objects easier to compare side by side.
Tips for the best results
- Use 2-space indentation for config files and 4 spaces when reading deeply nested data.
- Minify JSON before embedding it in a URL or an environment variable.
- Sort keys before comparing two API responses by eye.
- Use JSON Diff to compare two versions structurally.
Frequently asked questions
Why is my JSON invalid?
Common causes are trailing commas, single quotes instead of double quotes and unquoted keys.
Is my JSON sent to a server?
No. Formatting and validation happen entirely in your browser.
What is the difference between formatting and minifying?
Formatting adds indentation for readability. Minifying removes whitespace to make the file as small as possible.
Can I format JSON that contains comments?
Standard JSON does not allow comments. Remove them first, or the validator will report an error at the comment.
Is there a size limit?
Files of several megabytes format quickly in a modern browser.