Devbelt

JSON Formatter

Format, validate, explore & share instantly

Indent
INPUT
Formatted output appears here.
Paste JSON and hit Format.

Everything runs in your browser. Your JSON is never uploaded or stored on a server.

About

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"] }

Frequently asked questions

How do I format JSON online?
Paste your JSON into the input box and click Format (or press Ctrl/Cmd + Enter). Devbelt instantly pretty-prints it with your chosen indentation, either 2 spaces, 4 spaces, or tabs, and validates it at the same time.
Is my data safe? Is the JSON uploaded anywhere?
No. All formatting, validation, the tree view and even share links happen entirely in your browser using JavaScript. Your JSON is never sent to or stored on any server.
What does "Invalid JSON" mean and how do I fix it?
It means there is a syntax error, commonly a trailing comma, a missing quote, or an unclosed bracket. Devbelt shows the exact line and column of the problem so you can jump straight to it and fix it.
What is the difference between formatting and minifying JSON?
Formatting (beautifying) adds indentation and line breaks to make JSON readable. Minifying removes all unnecessary whitespace to make the JSON as small as possible for transport or storage.
Can I share formatted JSON with someone?
Yes. Click Share and Devbelt encodes your JSON into the link itself. Opening that link loads the JSON automatically, and because it lives in the URL, nothing is ever uploaded or made public.
Can I download the formatted JSON?
Yes. The Download button saves the formatted output as a .json file. Like everything else here, the file is created in your browser, so nothing is uploaded to do it.
How large a file can it handle?
The formatted view handles large payloads comfortably. The interactive tree view switches off above roughly 8,000 nodes to keep scrolling smooth, and the formatted view shows the whole thing without slowing down.

Related tools