JSON Formatter & Validator
Format, validate and minify JSON — privately, in your browser
This JSON Formatter pretty-prints, validates and minifies JSON instantly — and because everything runs locally in your browser, your data never leaves your device. That matters: JSON often contains API keys, tokens, customer records and internal payloads that should never be pasted into a random website's server.
Paste any JSON and choose 2-space or 4-space formatting for readability, or Minify to strip all whitespace for production payloads. Invalid JSON gets a precise error with the line and column number of the problem, so you can find that missing comma in a 5,000-line file in seconds.
Common JSON errors this catches
- Trailing commas —
{"a": 1,}is valid JavaScript but invalid JSON - Single quotes — JSON strings and keys must use double quotes
- Unquoted keys —
{a: 1}works in JS objects, not in JSON - Comments — JSON has no comment syntax;
//or/* */break parsing - Special values —
undefined,NaNandInfinitydon't exist in JSON
Example
An API returns a minified 40KB response you need to inspect: {"user":{"id":42,"roles":["admin","editor"]},…}
Paste it, click Format (2 spaces), and the structure becomes readable with each key on its own line. When you're done editing, Minify collapses it back for the request body.
Frequently Asked Questions
How do I format JSON to make it readable?
Paste your JSON above and click Format — it re-indents every level with consistent spacing, one key per line. Choose 2 spaces (the most common convention) or 4 spaces. The result is standard 'pretty-printed' JSON any tool can read.
Is it safe to paste sensitive JSON into an online formatter?
Into most online formatters, no — anything pasted may travel to their servers. This tool is different: formatting happens entirely in your browser with JavaScript's built-in JSON.parse — nothing is transmitted anywhere. You can disconnect from the internet and it still works.
Why is my JSON invalid?
The top offenders: a trailing comma after the last item, single quotes instead of double quotes, unquoted keys, comments (JSON doesn't allow them), or a stray control character from copy-pasting. Paste it above — the validator reports the exact line and column of the first problem.
What is the difference between JSON formatting and minifying?
Formatting adds line breaks and indentation for human readability. Minifying removes every unnecessary space and newline, producing the smallest possible payload for network transfer. Both represent identical data — machines don't care, humans and bandwidth do.
Are trailing commas allowed in JSON?
No. {"a": 1,} fails in every compliant parser, even though the same syntax is fine in JavaScript, Python and most modern languages. This mismatch is the single most common JSON error when hand-editing config files.
Can JSON have comments?
Standard JSON cannot — // and /* */ both make it invalid. Some tools accept JSONC (JSON with comments), like VS Code settings files and tsconfig.json, but APIs and parsers expecting pure JSON will reject them. A common workaround is a "_comment" key.
Should JSON keys use single or double quotes?
Double quotes, always — for both keys and string values. 'single quotes' are invalid JSON, another habit carried over from JavaScript. If your JSON came from a Python dict via str() instead of json.dumps(), this is why it won't parse.
How do I validate JSON from an API response?
Paste the raw response body above and click any button — validation runs first. If it's invalid you'll get the error position; a common surprise is an HTML error page (starting with <) returned where JSON was expected, meaning the API call itself failed.
What is the maximum size of a JSON file?
The format has no limit; practical limits come from parsers and memory. Browsers comfortably handle tens of megabytes with JSON.parse. This tool processes everything in-memory locally, so large files work — though beyond ~50MB the browser tab may slow down.
Why does JSON.parse fail on my JavaScript object?
Because a JavaScript object literal isn't JSON: unquoted keys, single quotes, trailing commas, undefined, NaN, Date objects and functions are all valid in JS but not in JSON. Serialize with JSON.stringify(obj) instead of pasting the object's source code.
Does key order matter in JSON?
Per the spec, no — objects are unordered collections, and two JSON documents with the same keys in different order are semantically equal. In practice most parsers preserve insertion order, but you should never rely on it; if order matters, use an array.
What is JSON used for?
JSON (JavaScript Object Notation) is the standard data format of the web: REST API requests and responses, configuration files (package.json, tsconfig.json), data storage, log records, and inter-service messages. It won over XML by being lighter, easier to read, and natively supported in every major language.