JSON Formatter
Format, validate, explore & share instantly
Everything runs in your browser. Your JSON is never uploaded or stored on a server.
Most JSON you deal with shows up as one long unreadable line, and the bug you're chasing is usually a missing bracket or a stray comma buried somewhere in the middle of it. Paste it here and you get it back cleanly indented. If it's broken, you get the exact line and column instead of a vague error message. From there you can walk it as a collapsible tree, minify it again, or drop it into a share link. It all runs in your browser, so a production response you paste in never touches a server.
What formatting actually does
JSON is how nearly everything on the web moves data around: API responses, config files, log lines. To save bandwidth it usually travels minified, squeezed onto a single line with the whitespace stripped out. A machine parses that fine. You, trying to find one field in it, do not.
Formatting puts the structure back. It adds the indentation and line breaks so you can see which keys sit inside which object, where an array starts and stops, and how deep the nesting goes. And since the tool has to parse the whole thing before it can format it, formatting doubles as a validity check. If it formats cleanly, your JSON is valid. If it can't, it tells you exactly where the problem is.
How it works
Two things happen when you hit Format. First the input goes through a strict JSON parser, and the moment it hits something the grammar doesn't allow, it stops and reports where. Then, once there's a valid structure in memory, it rebuilds the text with whatever indentation you picked, whether that's two spaces, four spaces, or tabs.
The tree view works off that same parsed structure. Instead of printing text, it renders each object and array as a node you can collapse. That's how you dig through a huge payload to find the one field you care about without scrolling past thousands of lines.
The mistakes JSON rejects
JSON looks like a JavaScript object, but it's stricter, and that catches people out constantly. These are the ones you'll hit most:
- A trailing comma after the last item breaks it. {"a": 1,} is invalid.
- Keys have to be in double quotes. {a: 1} won't parse; {"a": 1} will.
- Single quotes don't count. Only double quotes are allowed.
- There are no comments in JSON. Both // and /* */ are out.
- The only values allowed are objects, arrays, strings, numbers, true, false and null. No undefined, no functions, no dates.
Nine times out of ten a failed format is one of these, and the line and column tell you which one.
Invalid: { name: 'Cat', tags: ['a', 'b',] }
Valid: { "name": "Cat", "tags": ["a", "b"] }