Leading Zero in JSON Number – Why 01 Is Invalid

Local only

Standard JSON numbers cannot use unnecessary leading zeros. Values such as 01 or 007 are invalid numbers and may need either the zero removed or the value stored as a string.

Indent

19 chars · 3 lines

Two-way sync · Edit either side and the other updates automatically.

Invalid JSONLeading zeroes are not allowed in JSON numbers
Line 2Column 15Character 17Found “1”
"attempt": 01

JSON number syntax error

Why JSON numbers cannot start with a leading zero

JSON numeric grammar treats zero as a complete integer unless a decimal or exponent follows. Writing 01 therefore looks like one number ending at 0 followed immediately by another numeric token. This tool is free to use. No account or payment is required.

Last updated

What you can do here

  • Browser-local JSON processing
  • Route-specific malformed JSON example
  • Focused parser or repair guidance
  • Broken and corrected JSON example
  • Related JSON problem navigation

Steps

  1. Locate the numeric token beginning with 0 at the parser position.
  2. Remove unnecessary leading zeros when the value is an ordinary number.
  3. Use a quoted string instead when zeros are significant, such as codes or identifiers.

Numbers and identifiers have different semantics

A count of 01 and a count of 1 represent the same numeric value, so the valid JSON number is 1. A code such as 00123 may need to remain five characters long and therefore belongs in a string.

  • Counters copied with display padding.
  • ZIP codes, account fragments, or product codes modeled as numbers.
  • Legacy data formats that permit octal-like notation.

Do not preserve formatting by abusing number syntax

If leading zeros carry business meaning, model the field as text. Removing the zeros simply to satisfy the parser can change identifiers even though it preserves numeric value.

Leading zero JSON number example

The numeric attempt count should be written as 1 rather than 01.

Invalid JSON number

{
  "attempt": 01
}

Valid JSON number

{
  "attempt": 1
}

Common questions

Frequently asked questions

Is 01 a valid JSON number?

No. Standard JSON does not allow an integer to contain an unnecessary leading zero.

How should I store 00123 in JSON?

If the leading zeros are meaningful, store the value as a string such as "00123" rather than as a number.

Does JSON support octal number notation?

No. JSON has a single decimal number grammar and does not support JavaScript-style octal literals.

Debugging a specific JSON issue? Browse JSON troubleshooting.