JSON Formatter & Validator
Beautify, minify and validate JSON in your browser, with error messages that point at the character that broke it rather than just saying invalid.
JSON quietly changes large integers
The JSON specification puts no limit on how big a number may be — write as many digits as you like and the document is still valid. Every mainstream parser then loads it into a 64-bit floating point number, which holds integers exactly only up to 253 − 1 = 9,007,199,254,740,991. Above that, digits are rounded to the nearest representable value with no error and no warning:
| Written | Comes back as | |
|---|---|---|
| 9007199254740991 | 9007199254740991 | exact |
| 9007199254740992 | 9007199254740992 | exact |
| 9007199254740993 | 9007199254740992 | changed |
| 9007199254740995 | 9007199254740996 | changed |
| 9223372036854775807 | 9223372036854776000 | changed |
The parse succeeds every time. The number is simply different.
Which matters because identifiers are exactly this size
A signed 64-bit integer runs to 9,223,372,036,854,775,807 — which is what database keys, snowflake ids and Discord ids all are. They are about a thousand times too big for a double to hold exactly. Testing random 19-digit ids, 99% fail to survive a JSON round trip.
The largest 64-bit integer shows how well hidden this is. Parsed, it becomes
263 — one more than what was written. JavaScript then prints that as
9223372036854776000, because that is the shortest decimal identifying the same
double. So the number you get back and the number you see printed are both different from what
you sent, and different from each other.
The fix is not a bigger number type. It is to send identifiers as strings, which is why every API that learned this the hard way now does. If a value is an identifier rather than a quantity, arithmetic on it is meaningless anyway, and a quoted string cannot be silently rounded.
Decimals inherit the same trouble wholesale: 0.1 and 0.2 parsed from
JSON and added give 0.30000000000000004, not 0.3. That is floating point rather
than JSON, but JSON is where most people meet it.
How to use
- Paste your JSON into the input box.
- Choose beautify to indent it, or minify to strip whitespace.
- Read the error position if validation fails.
- Copy the result or download it as a file.
Frequently asked questions
Why is my JSON invalid?
The usual culprits are a trailing comma after the last item, single quotes instead of double, unquoted keys, or a stray comment. JSON is far stricter than JavaScript object syntax, and all four of those are legal in JavaScript and illegal in JSON, which is why they slip through so often.
Are comments allowed in JSON?
No. The format deliberately excludes them, which is a frequent complaint from anyone using JSON for configuration. Variants like JSON5 and JSONC add comments back, and some tools accept them, but a strict parser will reject the file.
Does my data get uploaded anywhere?
No. Parsing and formatting run entirely in your browser, so nothing is sent to a server. That matters for JSON containing API responses, tokens or customer records — the kind of thing that should never be pasted into an unknown web service.
What is the difference between beautifying and minifying?
Purely whitespace. Beautifying adds indentation and line breaks so a human can read the structure; minifying removes every optional space to make the file as small as possible. The data is identical either way, and no parser can tell the difference.
Why do my keys come back in a different order?
Because JSON objects are unordered by specification, so a parser is free to reorder them. Most preserve insertion order in practice, but nothing guarantees it — if order matters to you, an array is the correct structure, not an object.
What about very large numbers?
This is a real trap. JSON numbers are parsed as double-precision floats in JavaScript, so integers beyond about 9 quadrillion lose precision silently. A 64-bit database identifier can come back subtly wrong with no error raised, which is why such identifiers are usually transmitted as strings.
🔒 This tool runs entirely in your browser. Nothing you enter is uploaded, logged, or stored.