Skip to content
JS
Tool

JSON Formatter & Validator

Validate, prettify or minify JSON. Parse errors show the line and column.

152 bytes
Valid JSON · 5 keys · 152 bytes
14 lines · 207 bytes

The input is read by a small parser that follows the JSON grammar in RFC 8259 and keeps the exact text of every number and string. Format and Minify rebuild the output from that parse.

  • Numbers keep their original text. 12345678901234567890, 1.0 and 1e3 come out unchanged.
  • Validation runs 150 ms after you stop typing. Errors give the line and column in your input, and the line is highlighted.
  • Sort keys orders object keys by UTF-16 code unit, the same order as Array.prototype.sort() with no compare function. Arrays keep their order.
  • Share link encodes the input as Base64URL in the URL fragment. Inputs up to 8 KB after encoding can be shared.

A large integer ID keeps every digit:

{"id":12345678901234567890,"price":1.0}

{
  "id": 12345678901234567890,
  "price": 1.0
}

A trailing comma is reported at the comma:

{"a": 1,}

Line 1, column 8: Trailing comma is not allowed

Sort keys with Minify:

{"b": 2, "a": {"d": 4, "c": 3}}

{"a":{"c":3,"d":4},"b":2}
  • Reading a minified API response copied from the browser Network tab or a curl command.
  • Finding the line of a syntax error in a JSON file such as package.json.
  • Minifying JSON before storing it in an environment variable or a test fixture.
  • Sorting keys so two JSON documents can be compared line by line in the diff checker.
  • Checking whether a payload with 64-bit integer IDs would lose precision in JavaScript.
What causes a JSON parse error?
The most common causes are a trailing comma after the last item, single quotes instead of double quotes, unquoted keys, a missing comma between items, comments, and unescaped line breaks or tabs inside strings. JSON allows none of these.
Why do large numbers change in other JSON formatters?
Most formatters run JSON.parse() and then JSON.stringify(). JavaScript stores numbers as 64-bit floats, which hold integers exactly only up to 2^53 - 1 (9,007,199,254,740,991). Larger integers, such as 64-bit database IDs, are rounded. This tool formats the original text instead, so every digit is kept.
What happens to duplicate keys?
RFC 8259 says object names should be unique but does not forbid duplicates. JSON.parse() keeps only the last value. This tool keeps every entry in the output and lists the first three duplicate paths.
Is my JSON sent to a server?
No. Parsing and formatting run in your browser. A share link stores the JSON in the part of the URL after #, which browsers do not send to the server.

Related tools