Skip to content

JSON formatter and validator

Free, no sign-up Runs in your browser

Format, minify and validate JSON with the line and column of any error. Finds duplicate keys and numbers too large for a double, which JSON.parse hides.

Output
Formatted
The result appears here.

Everything you type here stays in your browser. Nothing is sent to HardenKit or to anyone else.

How to use the JSON formatter and validator

  1. Paste the JSON.
  2. If it is not valid, go to the line and column in the error.
  3. Choose the indentation, or minified, and copy the result.
  4. Read the findings for duplicate keys and numbers that lose precision.

About this tool

JSON has a small, strict grammar: double-quoted strings, no trailing commas, no comments, no single quotes. Most broken JSON breaks one of those rules, and the hard part is finding where. This tool validates against RFC 8259 and reports the line, the column and what was expected in plain words, then formats the document with the indentation you choose or minifies it to one line.

It also reports two things that are valid JSON and still cause bugs. The first is duplicate keys. {"role": "user", "role": "admin"} parses without error almost everywhere, but parsers disagree on which value wins. When a gateway validates one and the service behind it uses the other, an attacker can pass a check with one value and act with the other.

The second is numbers. JSON puts no limit on digits, but JavaScript and many other parsers store every number as a 64-bit float, exact only up to 9007199254740991. A larger ID is silently rounded to a neighbor, so two systems can disagree about which record they mean. The formatter here works on the text itself, so it never changes a number, and it lists every one that would not survive.

Sources

Questions

How do I find the error in my JSON?

Paste it here and read the message: it gives the line, the column and the cause. The usual causes are a trailing comma, single quotes, an unquoted key, a comment, or a missing comma between two items.

Are duplicate keys allowed in JSON?

The grammar allows them, and RFC 8259 says names should be unique and that behavior is unpredictable when they are not. Most parsers keep the last value without warning. Because parsers differ, duplicate keys are a known source of security bugs between services.

What is the largest number JSON can hold safely?

JSON itself has no limit, but for interoperability stay within plus or minus 9007199254740991, which is 2 to the power 53 minus 1. Beyond that, parsers that use doubles round the value. Send larger IDs as strings.

Does JSON allow comments or trailing commas?

No. Formats such as JSON5 and JSONC do, and some config loaders accept them, but a standard JSON parser rejects both.

Is my JSON sent to a server?

No. Validation and formatting run in your browser, so API responses and config files with secrets in them stay on your machine.

Related tools