JSON Formatter and Validator

Paste JSON to check that it is valid, indent it for reading, or squeeze it onto one line. When something is wrong, the tool points to the line and column where parsing failed.

How to use the JSON Formatter and Validator

  1. Paste your JSON into the input box. The tool validates it as you type and shows a green or red message.
  2. Choose the indentation (2 spaces, 4 spaces or a tab) and, if you want, tick "Sort keys A-Z".
  3. Press Format to pretty-print, or Minify to remove all optional whitespace.
  4. Copy the result with "Copy result". If the input is invalid, fix the character at the reported line and column and try again.

What counts as valid JSON

JSON is defined by RFC 8259 and is stricter than a JavaScript object literal. Property names and strings must use double quotes, trailing commas are not allowed, and comments are not part of the format. A value can be an object, array, string, number, true, false or null, so even a bare number such as 42 is a valid JSON document.

The most common errors are a trailing comma after the last item, single quotes around strings, an unquoted key, and a missing comma between two items. The error position this tool reports is where the parser could no longer continue, which is often just after the real mistake.

Pretty-printing, minifying and key order

Pretty-printing only changes whitespace, so it is safe for configuration files and API responses you want to read. Minifying removes that whitespace to reduce size, which helps when JSON is embedded in a URL, a log line or a request body.

Sorting keys makes two documents easier to compare, because equal objects then produce identical text. Array order is never changed, since the order of array items carries meaning. Duplicate keys in an object are collapsed by the parser: the last value wins.

Numbers and precision

JSON itself does not limit number size, but this tool, like JavaScript, reads numbers as 64-bit floating point values. Integers above 9,007,199,254,740,991 (2^53 - 1) can lose precision when re-printed. If you work with large identifiers, keep them as strings in your JSON.

Frequently asked questions

Is my JSON sent to a server?

No. Validation and formatting run entirely in your browser, so API responses and configuration files you paste stay on your device.

Why does my JSON with comments or a trailing comma fail?

Standard JSON allows neither. Formats such as JSONC or JSON5 do, but they must be converted to plain JSON before strict parsers will accept them. Remove the comments and the last comma, then validate again.

Why did a long number change after formatting?

Numbers are parsed as 64-bit floating point values, which are exact only up to 9,007,199,254,740,991. Larger integers are rounded. Store such values as strings if exact digits matter.

Does sorting keys change the meaning of the data?

No for objects, because JSON objects are unordered collections of properties. Arrays keep their order. Sorting is useful for comparing documents or producing stable output.

Is there a size limit?

There is no fixed limit, but everything is processed in memory in your browser tab. Documents of several megabytes work on most devices; very large files may feel slow on phones.