</>
ValidateHTML

Invalid Number Format in JSON

JSON numbers have strict formatting rules. They cannot have leading zeros (except 0 itself), cannot use hexadecimal (0xFF), cannot have a trailing decimal point (10.), and cannot start with a plus sign (+10). Only standard decimal notation and scientific notation (1.5e10) are allowed.

Why It Matters

The JSON parser rejects the document at the invalid number. This commonly occurs when copying numbers from programming languages that have more flexible number formatting rules.

Common Causes

  • Copying numbers from code that uses hex (0xFF), octal (0755), or a leading zero, none of which JSON accepts.
  • Writing a value like 10. with a trailing decimal point and no following digit.
  • Prefixing a positive number with a plus sign, which JSON does not allow.

Code Examples

Invalid JSON
{
  "count": 01,
  "hex": 0xFF,
  "price": 10.,
  "positive": +5,
  "octal": 0755
}
Valid JSON
{
  "count": 1,
  "hex": 255,
  "price": 10.0,
  "positive": 5,
  "octal": 493
}

How to Fix

  • 1Remove leading zeros from numbers. Use 1 not 01, use 7 not 007.
  • 2Convert hexadecimal values to decimal: 0xFF becomes 255.
  • 3Always include a digit after the decimal point: 10.0 not 10.
  • 4Remove the plus sign from positive numbers: 5 not +5.

Frequently Asked Questions

What number formats are valid in JSON?
Per RFC 8259, decimal integers and floats with an optional leading minus and optional exponent: -5, 3.14, 1.5e10. No leading zeros, no hex, no octal, no leading plus, and no trailing decimal point.
Can JSON numbers have a leading zero?
No, except for the single digit 0 and decimals like 0.5. A value like 01 or 0755 is a parse error. Remove the leading zero, or convert an octal value to its plain decimal form.
How do I represent very large or precise numbers safely?
JSON itself sets no size limit, but parsers usually load numbers into a double, which loses precision beyond 2^53. For large integers or exact decimals, store the value as a string and convert it in your code.

Check Your JSON Now

Our JSON validator detects this error automatically and shows the exact line and column.

Open JSON Validator
Recommended

Cloudways · Managed Cloud Hosting

Fix this JSON error, then deploy on Cloudways managed cloud (AWS, GCP, DigitalOcean).

Free 3-day trial · 30% off 3 months + free site migration with code MIGRATE303

Start free trial

Related JSON Errors

View all JSON errors