Nested JSON, formatted and minified
A compact nested object grows when formatted with two spaces and returns to the same compact text when minified.
Input, 111 B
{"kit":"sample","ready":true,"count":2,"note":null,"tags":["pdf","json"],"nested":{"locale":"en","weight":1.5}}
Settings | Format | JSON.stringify with 2 spaces |
| Minify | JSON.stringify with no extra space |
Observed results
Format, 164 B
{
"kit": "sample",
"ready": true,
"count": 2,
"note": null,
"tags": [
"pdf",
"json"
],
"nested": {
"locale": "en",
"weight": 1.5
}
}
Minify, 111 B
{"kit":"sample","ready":true,"count":2,"note":null,"tags":["pdf","json"],"nested":{"locale":"en","weight":1.5}}
What to check
Formatting changed 111 B to 164 B. Minifying that formatted text returned 111 B, identical to the input. Keys, true, null, and 1.5 stayed the same. The status “Valid JSON” here means the text parsed. A schema check is a separate step.
Caveats
- Minify matched the input because the input was already compact. It does not shrink every document.
- The formatted and minified files are the exact strings, with no extra trailing newline.
Integers outside the safe range are refused
An unquoted integer above 9007199254740991 is rejected so the formatter does not write a different number.
Refused input, 47 B
{"reference":9007199254740993,"label":"unsafe"}
Settings | Safe inclusive bound | ±9007199254740991 |
| Refused token | 9007199254740993 |
Tool result
This JSON contains an integer outside JavaScript's safe range. To avoid changing its digits, store that value as a quoted string before formatting.
What to check
The formatted output was left empty. JSON.parse alone turned 9007199254740993 into 9007199254740992. The formatter then finds that original token and does not write the changed number. The same refusal happened for 9007199254740992 and for -9007199254740993. The integer 9007199254740991 formatted unchanged, to a 35 B document.
Caveats
- Quoting the digits works. quoted-large-integer.json formats to a 58 B document and keeps 9007199254740993 as a string.
- A decimal token skips the integer check. decimal-large-number.json uses 9007199254740993.0 and the formatter writes 9007199254740992. Quote the value, or keep it an integer inside the safe bound, when every digit matters.
Example files
- Download unsafe-integer.json Input. Unquoted 9007199254740993, 47 B. The formatter refuses it.
- Download unsafe-power-of-two.json Input. Unquoted 9007199254740992, 30 B. Also refused.
- Download unsafe-negative-integer.json Input. Unquoted -9007199254740993, 31 B. Also refused.
- Download safe-integer-boundary.json Input. 9007199254740991, 30 B. This integer is accepted.
- Download safe-integer-boundary-formatted.json Output. Formatted safe integer, 35 B, digits unchanged.
- Download quoted-large-integer.json Input. The same digits stored as a string, 49 B.
- Download quoted-large-integer-formatted.json Output. Formatted quoted integer, 58 B, digits unchanged.
- Download decimal-large-number.json Input. Decimal token 9007199254740993.0, 32 B.
- Download decimal-large-number-formatted.json Output. Formatter result, 35 B, with the number changed to 9007199254740992.
A trailing comma is invalid JSON
The formatter reports the parser detail and does not guess a repair.
Input, 24 B
{
"label": "sample",
}
Tool result
This is not valid JSON. Expected double-quoted property name in JSON at position 23 (line 3 column 1)
What to check
The output was left empty. The sentence after the period is the V8 parser detail observed on Node.js 22.19.0. Another browser engine can word that detail differently. Position 23 is the closing brace on line 3, after the trailing comma.
Caveats
- The tool does not remove the comma for you. A silent repair could change a different document.
Valid syntax can still be the wrong shape
An object whose pages value is the string “two” formats successfully.
Input, 29 B
{"status":"ok","pages":"two"}
Formatted JSON, 38 B
{
"status": "ok",
"pages": "two"
}
What to check
The formatter accepted this text. A schema that required pages to be a number would reject the string “two”. This page checks JSON syntax only. Field names, types, and API contracts need a separate schema check.
Caveats
- The tool status “Valid JSON” describes the parse. It is not approval of the data’s shape.