JSON Formatter and Validator
Free JSON formatter and validator that beautifies, minifies and checks JSON in your browser, with syntax errors reported by line and column.
How to use the JSON formatter
- Paste your JSON into the input box.
- Choose an indentation style: 2 spaces, 4 spaces or tabs. Turn on “sort keys” if you want object keys in alphabetical order.
- Click format to pretty-print the JSON, or minify to compress it onto a single line.
- If the JSON is invalid, read the error message, which gives the line and column of the problem, fix it and try again.
- Copy the result and use it in your code, documentation or API client.
What this tool does
JSON (JavaScript Object Notation) is the most common format for exchanging data between web services, and for configuration files. Raw JSON from an API is often a single dense line that is hard to read. This tool makes it readable, checks that it is valid, and can shrink it back down when you need a compact version.
- Format (beautify): adds line breaks and consistent indentation so the nesting of objects and arrays is easy to follow. You can indent with 2 spaces, 4 spaces or tabs to match your project’s style.
- Minify: removes all unnecessary whitespace to produce the smallest valid JSON, useful for payloads, embedding in code or reducing file size.
- Validate: checks that your input is well-formed JSON. If it isn’t, the tool shows the syntax error with its line and column so you can find it quickly.
- Sort keys: reorders the keys of every object alphabetically. This makes large objects easier to scan and makes two JSON documents much easier to compare side by side.
Common JSON errors
When validation fails, the cause is usually one of these:
- Trailing commas:
{"a": 1,}is not valid JSON, even though many programming languages allow it. - Single quotes: JSON strings and keys must use double quotes.
{'name': 'Ana'}is invalid. - Unquoted keys:
{name: "Ana"}is valid JavaScript but not valid JSON. - Comments: standard JSON does not allow
//or/* */comments. - Missing commas or brackets: a forgotten comma between two items or an unclosed
}or]. - Special values:
undefined,NaNandInfinityare not part of JSON.
The line and column in the error message point to where the parser noticed the problem. The real mistake is sometimes just before that position, for example a missing comma at the end of the previous line.
Safe for sensitive data
All formatting, minifying and validation happen locally in your browser. Your JSON is never sent to a server. This matters because JSON often contains sensitive information: API responses with customer data, access tokens, internal configuration files or logs. With this tool, that data stays on your machine.
Frequently asked questions
Is my JSON sent to a server?
No. The tool runs entirely in your browser, so your data never leaves your device. You can use it with API responses, configuration files and other confidential data.
What is the difference between formatting and minifying?
Formatting adds line breaks and indentation to make JSON easy for people to read. Minifying removes all unneeded whitespace to make it as compact as possible for machines. Both produce the same data.
Should I use 2 spaces, 4 spaces or tabs?
It is purely a matter of style, and the data is identical either way. Two spaces is common in JavaScript projects and API documentation, 4 spaces is common in Python projects, and tabs let each reader choose their display width. Pick whatever matches your project.
Does sorting keys change my data?
No. In JSON, the order of keys in an object has no meaning, so sorting them doesn’t change the data. The order of items in arrays is never changed.
Why does the error point to the wrong line?
The parser reports the position where it realized the JSON was invalid. If you forgot a comma or a closing quote, that is often at the start of the next line or value. Look just before the reported position too.
Can it fix invalid JSON automatically?
No. The tool validates your JSON and tells you exactly where the syntax error is, but it doesn’t guess at corrections. Fix the reported error and format again.
Related tools
- Base64 Encoder and Decoder Free Base64 encoder and decoder with full UTF-8 support and a URL-safe base64url option. Runs entirely in your browser, nothing is uploaded.
- URL Encoder and Decoder Free URL encoder and decoder. Percent-encode query parameters or full URLs, decode %XX sequences and handle + as space. Runs in your browser.
- UUID Generator Free UUID generator for version 4 and version 7 UUIDs. Create up to 1,000 at once, uppercase or without hyphens, then copy or download as .txt.