DevNex

JSON Formatter

Format and validate JSON instantly.

Private · Runs entirely in your browser

What is a JSON formatter?

A JSON formatter takes JSON that is hard to read and rewrites it with line breaks and indentation, so its structure becomes visible. JSON itself does not care: {"a":1} and the same object spread over four indented lines are the same document to every parser. Formatting exists for the reader, not the machine.

That matters because the JSON developers actually deal with arrives minified — from a log line, a network panel, a webhook body. A single line of 4,000 characters becomes a shape you can scan, where you can see that items is an array of three objects and that one of them is missing a field.

This tool formats by parsing the text and writing it back out, in your browser. That has one useful consequence and one worth knowing about. The useful part: if it produces output, that output is definitely valid JSON, because it came from a parser — formatting and validating are the same operation here. The part to know: two things get normalised on the way through. Escape sequences are written in their shortest valid form, so "A" comes back as "A". And if an object has the same key twice, only the last one survives, which is what any parser reading your document would also do.

JSON Formatter features

  • Format JSON as you type, with no button to press
  • Validate while formatting: output only exists if the input parsed
  • Choose two spaces, four spaces or tabs
  • Syntax highlighting that names the type of every value
  • Copy the result, or download it as a .json file
  • See the input and output size in bytes
  • Errors that give the line, the column and the likely cause
  • Everything runs locally in your browser

How to use it

  1. Paste your JSON into the input on the left. Formatting happens as you type.
  2. Pick an indentation width. Two spaces is the common default; tabs are worth choosing if the file is going into a repository that uses them.
  3. Copy the result, or download it as a .json file.

Everything is reachable from the keyboard. The input is a plain text area, so your editor shortcuts work, and the copy button announces itself to screen readers when it succeeds.

The four mistakes that cause most failures

JSON is a much smaller language than JavaScript, and almost every failure is a JavaScript habit leaking into it. When this tool recognises one of these, it says so by name instead of repeating the browser message.

A trailing comma

{
  "id": 1,
  "name": "Ada",
}

Legal in JavaScript, rejected by JSON. This is the most common cause by a wide margin, and the browser is at its least helpful here: Chrome reports Unexpected token '}' with no position at all for the array version of the same mistake. This tool tells you which line the comma is on.

Single quotes

{'name': 'Ada'}

JSON strings and keys are always double-quoted. There is no single-quote form. Note that the browser gives the identical message for this and for an unquoted key, which is why the explanation here comes from reading your text rather than from the parser.

An unquoted key

{name: "Ada"}

Object keys must be quoted strings, even when they look like ordinary identifiers. This one catches people copying an object literal out of source code.

A comment

{
  // the user id
  "id": 1
}

JSON has no comment syntax, deliberately. If you need comments in a config file, the format you want is JSON5, YAML, or TOML. Some tools accept // in JSON files anyway, which is why the file you were given might have them.

When to use something else

If you only need a yes or no answer and the location of the first problem, the JSON Validator is a shorter route, and it also reports duplicate keys, which formatting silently resolves. If you are going the other way and want the smallest possible payload, use the JSON Minifier.

For a document of a few megabytes, your editor is a better tool than any web page: it can fold sections and search inside them. This tool is for the payload you just pulled out of a log or a network panel and want to read right now.

Privacy

The formatter runs entirely in your browser. There is no upload step and no server endpoint behind it, which is what makes it reasonable to paste an access token or a customer record while debugging. If you would rather verify than trust: open your browser developer tools, watch the network panel, and paste something. Nothing is sent.

Questions

Does formatting change my data?

The values are untouched. Whitespace is rewritten, and two things are normalised because a JSON parser normalises them anyway: escape sequences are written in their shortest valid form, and duplicate keys in the same object collapse to the last one. If you need to know whether a document has duplicate keys before that happens, use the JSON Validator, which reports them.

Why does my JSON fail when it works in JavaScript?

JSON is a much smaller language than JavaScript. Trailing commas, single-quoted strings, unquoted keys, comments and undefined are all valid JavaScript and none of them are valid JSON. Those four are the most common causes by a wide margin, and this tool names them specifically when it finds one.

Is there a size limit?

No hard limit, but syntax highlighting is switched off above about 100,000 characters, because rendering hundreds of thousands of coloured elements would make the page stutter without helping anybody read it. Formatting, copying and downloading still work at any size your browser can hold in memory.

Is the JSON Formatter free?

Yes, with no account, no trial and no cap on how many times you use it. There is nothing to sign up for. The site is intended to be supported by advertising, which is why you may see an ad beside the title or below the tool; the tool itself is not limited by it in any way.

Is my JSON sent anywhere?

No. The formatter is JavaScript running in your browser, and the page has no endpoint to send anything to. You can confirm it in your browser network panel: paste a payload and watch that no request is made.