JSON formatter online
Beautify or minify JSON, and when it is broken, get told exactly which line and character caused it.
Runs entirely in your browser. Your JSON is never uploaded.
How to use the JSON formatter
- Paste your JSON into the top box. It can be minified, badly indented, or broken — the point of the tool is to tell you which.
- Press Format JSON. If it parses, you get it back properly indented with the key count, nesting depth and size shown above the result.
- If it does not parse, the error message names the line and column where the parser gave up, along with what it found there. That is almost always one or two characters before the real mistake.
- Use Minify to strip every space and newline for production, or Tree view to explore a large document by collapsing the branches you do not care about.
What you can use it for
Reading an API response is the daily use. Anything that comes back from a REST endpoint arrives minified onto one enormous line, and finding a single nested field in that by eye is miserable. Formatted with two-space indentation, the structure becomes obvious in seconds.
Debugging a config file that suddenly stopped working is the other. package.json, composer.json, a theme settings file, a Google Search Console structured data block — one trailing comma breaks all of them, and the error your build tool prints is often much less specific than the line number you get here.
Sorting keys alphabetically is underrated for comparing two versions of the same object. Once both are sorted and formatted identically, you can drop them into the text diff checker and the actual changes stand out instead of drowning in reordering noise.
Minifying matters when JSON is being embedded rather than read. Structured data in a page head, a data attribute, or a payload sent on every request — stripping whitespace from a large object can remove a meaningful chunk of bytes, and nothing reads it by eye anyway.
Things to know about JSON
The three things that break JSON most often are trailing commas, single quotes, and comments. JavaScript object literals allow all three; JSON allows none of them. If you copied an object out of a .js file, those are the first things to check.
Keys must be double-quoted strings. {name: "x"} is valid JavaScript and invalid JSON — it has to be {"name": "x"}. Values may be strings, numbers, true, false, null, arrays or objects, and nothing else. There is no date type, no undefined, and no NaN.
Very large numbers lose precision. JSON numbers are parsed as JavaScript doubles, so any integer above about 9 quadrillion is silently rounded. APIs that use 64-bit IDs — Twitter and several payment gateways among them — send those IDs as strings for exactly this reason.
Formatting happens by parsing your text into a real object and re-serialising it. That means the output is guaranteed to be valid JSON, but it also means insignificant details are normalised: 1.0 becomes 1, and duplicate keys collapse to the last one that appeared. Both are correct behaviour, and both can surprise you.
Frequently asked questions
Look one or two characters before the position the error names. The parser reports where it realised something was wrong, not where the mistake is. The usual culprits are a trailing comma after the last item in an object or array, a single quote instead of a double, or a stray character pasted in from a word processor such as a smart quote.
No. Parsing and formatting use the browser's built-in JSON functions in your own tab. Nothing is transmitted, which matters when the JSON you are debugging contains API keys, tokens or customer records — a great many online formatters do send it.
Not as a single document, because those formats are several separate JSON objects on consecutive lines rather than one valid document. Format one line at a time, or wrap the whole set in square brackets with commas between the objects to turn it into a valid array first.
How many levels of nesting the deepest branch has. A flat object is depth 1. An object containing an array of objects is depth 3. It is a quick way to gauge how complicated a response is before you start writing code to walk it.
No. Whitespace between tokens is not significant in JSON, so a minified document parses to exactly the same object. It is purely a size optimisation, and it is safe to do on anything a machine will read.