Quick answer

JSON numbers must be decimal.

JSON Invalid Number Format

JSON numbers must be decimal. No leading zeros (except 0.x), no NaN or Infinity, no hex or octal.

Common causes

How to fix

Examples

Bad

{"n": 07}

Good

{"n": 7}

JSON invalid number format errors happen when a value does not follow the JSON number grammar defined by the JSON specification. This validator helps developers, QA teams, and API integrators identify common issues such as leading zeros, unsupported values like NaN and Infinity, hexadecimal or octal notation, and malformed decimal syntax. It is especially useful when debugging API payloads, configuration files, log ingestion pipelines, and application data that must be parsed consistently across systems. Use it to quickly isolate formatting problems before they break parsing, validation, or downstream processing.

How This Validator Works

This checker evaluates whether a numeric token matches standard JSON number rules. JSON numbers must be written in decimal form and may include an optional minus sign, an integer part, an optional fractional part, and an optional exponent. The validator flags values that fall outside that grammar, including numbers with leading zeros, non-decimal prefixes, or special floating-point values that are valid in some programming languages but not valid JSON.

Common Validation Errors

Most JSON number errors come from copying numeric values from application code into JSON without converting them to JSON-safe syntax. Another common issue is assuming that formats accepted by JavaScript, Python, or other languages are also valid JSON. JSON is stricter than many runtime numeric systems, so even small differences can cause parsing failures.

Where This Validator Is Commonly Used

JSON number validation is commonly used anywhere structured data is exchanged between systems. It is especially important in API development, frontend-backend data transfer, ETL pipelines, configuration management, and automated testing. Teams also use it when validating webhook payloads, event streams, and machine-generated JSON from integrations or AI workflows.

Why Validation Matters

Valid JSON numbers help ensure data can be parsed reliably by standards-compliant tools, browsers, servers, and databases. When numeric syntax is invalid, parsers may reject the entire document or silently mis-handle the value depending on the implementation. Validating early reduces debugging time, prevents broken integrations, and improves consistency across services that may not interpret non-standard numeric formats the same way.

Technical Details

According to JSON number grammar, a number may be negative, but the integer portion cannot contain unnecessary leading zeros. The allowed forms are based on decimal notation only. JSON does not support language-specific numeric literals such as hexadecimal, octal, binary, NaN, or infinite values. This strictness is part of what makes JSON portable across systems and implementations.

Rule Valid Example Invalid Example
Decimal integer 0, 42, -7 01, -01
Fractional part 0.5, -12.75 .5, 1.
Exponent 1e3, -2.5E-4 1e, 2E+
Special values Not supported in JSON NaN, Infinity

Frequently Asked Questions

What is an invalid JSON number format?

An invalid JSON number format is any numeric value that does not match JSON’s strict number syntax. Common examples include leading zeros, missing digits around a decimal point, incomplete exponents, and special values such as NaN or Infinity. Even if a language runtime accepts the value, JSON parsers may reject it.

Why is 01 invalid in JSON?

JSON does not allow unnecessary leading zeros in numbers. The value 01 is invalid because the integer portion must be either 0 or a non-zero digit followed by digits. This rule prevents ambiguity and keeps number parsing consistent across implementations.

Are NaN and Infinity allowed in JSON?

No. JSON does not support NaN, Infinity, or -Infinity as numeric values. Some programming languages can represent these values, but they are not part of the JSON specification. If you need to transmit them, you usually have to encode them as strings or use a separate schema rule.

Can JSON numbers use hexadecimal or octal notation?

No. JSON numbers must be written in decimal notation only. Formats like 0x10 or 0o12 are not valid JSON numbers. If your source data uses those formats, convert them to decimal before serializing to JSON.

Why does .5 fail JSON validation?

JSON requires at least one digit before the decimal point. The valid form is 0.5, not .5. This rule is part of the standard number grammar and helps ensure consistent parsing across JSON libraries.

How do I fix a trailing decimal point like 1.?

Add digits after the decimal point or remove the decimal point entirely. For example, change 1. to 1.0 or 1, depending on the intended value. JSON requires digits on both sides of the decimal point when a fraction is used.

Does JSON allow plus signs in numbers?

JSON does not allow a leading plus sign on numbers. A value like +5 is invalid JSON. If the number is positive, write it without the plus sign, such as 5 or 5.2.

Can a JSON number contain commas or spaces?

No. JSON numbers must be contiguous numeric tokens without commas, spaces, or unit suffixes. Values like 1,000 or 12 kg are not valid JSON numbers. If formatting is needed for display, keep the raw JSON value separate from the presentation layer.

What should I do if my API returns invalid numeric values?

Check the serialization layer first. Many invalid JSON number issues come from converting native language values directly into JSON without sanitizing them. Review the source data, normalize special values, and ensure the output matches JSON number grammar before sending it to clients or downstream services.

Is this validator useful for debugging parser errors?

Yes. It is helpful when a parser reports a JSON syntax error and the suspected cause is a malformed number. By isolating the numeric token, you can quickly confirm whether the issue is a leading zero, unsupported special value, or another grammar violation before checking the rest of the document.

Related Validators & Checkers

FAQ

Can JSON have leading zeros in numbers?
No. 07 is invalid; use 7.
Can I use Infinity in JSON?
No. Use null or a string, or omit the value.

Fix it now

Try in validator (prefill this example)

Related

All tools · Canonical