JSON Formatter and Validator

Paste JSON to pretty-print it, minify it or check that it is valid. Errors point to the exact line and column. Everything runs in your browser and nothing is uploaded.

Loading the tool. It runs entirely in your browser...

How to format and validate JSON

Paste your JSON into the input box, or drop a .json file onto it, then press Format (or Ctrl+Enter). The result appears below with your chosen indentation: two spaces, four spaces or a tab. Minify removes every unnecessary space, which is what you want before sending a payload over the wire, and Validate only checks the syntax.

The parser follows the JSON standard strictly, so it rejects things JavaScript itself tolerates: trailing commas, single quotes, unquoted keys, comments and leading zeros. When something is wrong the message names the problem and the position, for example Line 3, column 8, and a Jump to error button selects the offending character. For common near-JSON mistakes, Try to fix common mistakes strips comments, converts single quotes and removes trailing commas.

Switch the output to Tree to collapse and expand objects and arrays, which is the fastest way to explore a large API response. Tick Sort keys to order object keys alphabetically, which makes two documents easier to compare.

Worked example

Input, copied straight from a log line:

{"user":{"id":7,"name":"Ann","roles":["admin","dev"]},"active":true}

Formatted with two spaces:

{
  "user": {
    "id": 7,
    "name": "Ann",
    "roles": [
      "admin",
      "dev"
    ]
  },
  "active": true
}

Now remove the closing quote after Ann. The tool now reports an error such as Expected "," or "}" but found "r" together with the line and column where parsing stopped, so you can go straight to the typo instead of scanning the whole document.

Good to know

  • Large files: inputs over 400 KB are formatted in a background worker so the page does not freeze. The tree view is skipped for those.
  • Big numbers: JSON numbers are read as JavaScript numbers, so integers beyond 9,007,199,254,740,991 lose precision. Keep such IDs as strings.
  • Duplicate keys: JSON allows them but most parsers keep only the last one. Sorting and formatting here keep the last value too.
  • Sharing: the share button puts small inputs in the link. Do not use it for secrets.

Frequently asked questions

Is my JSON uploaded anywhere?

No. The formatter runs entirely in your browser using JavaScript. Your data never leaves your device, which makes it safe for API responses and configuration files that contain private information.

Why does my JSON fail when it works in JavaScript?

JSON is stricter than JavaScript object syntax. Keys and strings need double quotes, trailing commas are not allowed, and comments are not part of the standard. The error message tells you which rule was broken and where.

What is the difference between formatting and minifying?

Formatting adds line breaks and indentation so people can read the data. Minifying removes all optional whitespace so the text is as small as possible. Both produce JSON with identical meaning.

Does sorting keys change the meaning of my JSON?

For objects, no: key order is not significant in JSON. Array order is never changed, because it is significant.

How large a file can I format?

Files of several megabytes work fine because heavy inputs are processed in a background worker. Very large files are limited only by your device memory. Files over 25 MB are not opened by the drop zone.