JSON Formatter & Validator

Beautify, validate, repair and minify JSON in your browser.

Indent
Input
Output
{
  "id": 1024,
  "name": "DIMA Tools",
  "active": true,
  "tags": [
    "json",
    "formatter",
    "validator"
  ],
  "owner": {
    "team": "web",
    "members": 3,
    "lead": null
  },
  "score": 4.8
}
Valid JSON

How to format JSON

  1. Paste your JSON into Input, open a .json file, or drop one on the box. It is formatted as you type.
  2. Pick an indent of 2 spaces, 4 spaces or tabs, and turn on Sort keys A–Z to order every object's keys alphabetically.
  3. Switch to Tree to fold objects and arrays and see how many keys or items each one holds.
  4. Copy the result or download it as formatted.json. Minify removes all whitespace for the smallest file.

Everything runs in your browser. Your JSON is never uploaded, so it is safe to format API responses, config files and tokens.

JSON validator: finding the error

If the JSON is invalid, the bar under the editor turns red and names the problem with its line and column, and the line itself is shown with the bad character highlighted. JSON is strict: one stray comma or a single quote breaks the whole document. The most common errors:

ErrorExampleFix
Trailing comma{"a": 1, "b": 2,}Delete the comma after the last item.
Single quotes{'name': 'Ann'}Use double quotes around keys and strings.
Unquoted key{name: "Ann"}Put the key in double quotes: "name".
Missing comma{"a": 1 "b": 2}Add a comma between items.
Comments{"a": 1 // note}JSON has no comments. Remove them.
Leading zero{"zip": 02134}Write it as a string, "02134", or drop the zero.
Python values{"ok": True, "x": None}Use true, false and null in lowercase.
NaN or Infinity{"ratio": NaN}JSON has no NaN. Use null or a string.
Line break in a string{"text": "line one↵line two"}Write the line break as \n.

Repair fixes most of these automatically. It accepts single quotes, unquoted keys, trailing commas, comments and Python's True, False and None, then rewrites the input as valid JSON.

Beautify vs minify

Beautified JSON has line breaks and indentation so people can read it. Minified JSON strips every unneeded space and line break, which makes API payloads and files smaller. Both hold exactly the same data. A typical response shrinks by 20% to 40% when minified, more when it was deeply indented.

Escape and unescape JSON

Escape turns the input into a single JSON string, with quotes and line breaks escaped, so you can embed JSON inside another JSON value or a code string. Unescape does the reverse: paste a quoted string such as "{\"a\":1}" and it becomes formatted JSON again.

JSON rules in short

  • Objects use { } with keys in double quotes; arrays use [ ].
  • Values are strings in double quotes, numbers, true, false, null, objects or arrays.
  • No trailing commas, no comments, no single quotes, no undefined.
  • Strings escape quotes, backslashes and control characters: \", \\, \n, \t, \u00e9.

JSON5 and JSONC, used by some config files such as tsconfig.json, allow comments and trailing commas. Repair converts them to standard JSON.

Frequently asked questions

Is my JSON uploaded anywhere?

No. Formatting, validation and repair all run in your browser, and nothing is sent to a server.

How do I find the error in my JSON?

Paste it in. The status bar shows the problem with its line and column, and the line is displayed with the wrong character highlighted.

Can it fix invalid JSON?

Yes. Repair converts single quotes, unquoted keys, trailing commas, comments and Python-style True, False and None into valid JSON.

How do I sort JSON keys alphabetically?

Turn on Sort keys A–Z. Keys in every nested object are sorted; array order is kept.

Can it handle large JSON files?

Yes, files of several megabytes format in your browser. The tree view loads large arrays as you open them.

What is the difference between a JSON formatter and a validator?

A validator checks that the JSON follows the rules; a formatter lays it out with indentation. This tool does both every time you paste.