JSON Formatter
Format, validate and minify JSON instantly. Get clear error messages with line and column numbers. Runs in your browser, so your data stays private.
Runs in your browser. Nothing is uploaded.
About the JSON Formatter
JSON (JavaScript Object Notation) is the most common format for exchanging data between web services, configuration files and apps. Machines don't care about whitespace, so JSON from APIs and logs often arrives as one long, unreadable line.
This formatter parses your JSON, tells you exactly where it's broken if it isn't valid, and re-prints it with consistent indentation so you can read it. It can also minify JSON, removing all unnecessary whitespace to make it as small as possible for sending or storing.
Because developers often paste API responses, tokens and configuration that contain secrets, this tool runs entirely in your browser. Your JSON is never sent to a server.
How to use it
- Paste your JSON into the “Your JSON” box, or press “Load sample” to try it out.
- Choose an indentation style: 2 spaces, 4 spaces or tabs.
- Press “Format & validate”. If the JSON is valid, the formatted version appears in the Result box.
- If it's invalid, read the error message: it gives the problem and the line and column where it was found.
- Use “Minify” instead to produce the most compact version.
- Copy the result to your clipboard or download it as a .json file.
Examples
Formatting an API response
{"id":7,"tags":["a","b"]} becomes a readable, indented block with each key on its own line, which makes nested objects much easier to follow.
Finding a trailing comma
{"name": "x",} is invalid because JSON does not allow a comma after the last item. The formatter reports the error and the exact column of the closing brace.
Single quotes
{'a': 1} is valid JavaScript but not valid JSON. JSON requires double quotes around keys and strings.
Minifying for transport
A 20-line formatted config minifies to a single line with no spaces, often 20–40% smaller, which helps when embedding JSON in URLs or environment variables.
Limitations
- Numbers larger than 9,007,199,254,740,991 (2⁵³−1) lose precision, because browsers store all JSON numbers as 64-bit floating point. Long IDs should be sent as strings.
- If an object contains the same key twice, only the last value is kept in the output, matching how JSON.parse behaves.
- Comments and trailing commas (allowed in JSON5/JSONC config files) are reported as errors, because they are not part of standard JSON.
- Very large documents (tens of megabytes) may make the page slow, since everything is processed on your device.
Frequently asked questions
Is my JSON uploaded anywhere?
No. Parsing and formatting use your browser's built-in JSON engine. The data never leaves your device, which makes the tool safe for API keys, tokens and private data.
What does “Unexpected token” mean?
The parser found a character it didn't expect at that position, such as a single quote, a missing comma, an unquoted key or a stray bracket. Check the line and column shown in the error message.
Why does the error position differ between browsers?
Each browser's JSON engine words its errors differently, and some (like Safari) don't report a position at all. The problem itself is the same; the formatter shows whatever detail your browser provides.
What's the difference between formatting and minifying?
Formatting adds line breaks and indentation for humans to read. Minifying removes every unnecessary space and line break so the data is as small as possible. Both contain exactly the same data.
Should I use 2 spaces, 4 spaces or tabs?
It's a matter of convention. 2 spaces is the most common for JSON (used by npm's package.json, for example). Match whatever the project you're working on already uses.