json

FormatValidateConvert

Unexpected number in JSON at position 7

A number written in a familiar shorthand may still be invalid JSON. JSON's number spelling is narrower than the notation a calculator, spreadsheet or programming language might accept: an integer cannot have spare zeros at its beginning, a fraction needs a digit before the decimal point, and a positive number does not begin with a plus sign. These three examples show the exact messages for each spelling and the correction this site's Repair makes.

A leading zero before more digits

Input

{"n": 012}

Do

  1. Paste the input into the validator.
  2. Press Repair in the editor band.

Result

Corrected number formats

{"n": 12}

Try it in the validator →

What each runtime prints for this input
RuntimeMessage
Chrome 153 · Node.js 26Unexpected number in JSON at position 7 (line 1 column 8)
Node.js 18 (older V8)Unexpected number in JSON at position 7
Firefox 156JSON.parse: expected ',' or '}' after property value in object at line 1 column 8 of the JSON data
Safari 26JSON Parse error: Expected '}'
Python 3.14 jsonExpecting ',' delimiter: line 1 column 8 (char 7)
This siteNumbers cannot have a leading zeroline 1, column 7

Recorded from each runtime; the wording is in Firefox’s, Safari’s and Python’s sources.

The zero in 012 can stand alone as a valid JSON number, but the following digit cannot extend it into this integer. Chrome reports position 7, line 1, column 8, pointing at the digit 1 after that zero. This site's parser gives the more direct explanation that numbers cannot have a leading zero, beginning at column 7. Firefox and Python describe missing punctuation after the value because the zero already looked like a complete value to them; Safari says it expected a closing brace.

If the value represents the decimal quantity twelve, write12. If it represents a fixed-width identifier whose spelling must remain 012, store "012" as a string instead. Removing the zero from an account code, postal code or product identifier changes the data even when the resulting number is valid. Do not infer an octal value from this spelling: JSON has no octal number syntax, so the producer needs to establish the intended meaning before conversion.

A decimal point without its integer part

Input

{"n": .5}

Do

  1. Paste the input into the validator.
  2. Press Repair in the editor band.

Result

Corrected number formats

{"n": 0.5}

Try it in the validator →

What each runtime prints for this input
RuntimeMessage
Chrome 153 · Node.js 26Unexpected token '.', "{"n": .5}" is not valid JSON
Node.js 18 (older V8)Unexpected token . in JSON at position 6
Firefox 156JSON.parse: unexpected character at line 1 column 7 of the JSON data
Safari 26JSON Parse error: Unexpected token '.'
Python 3.14 jsonExpecting value: line 1 column 7 (char 6)
This siteUnexpected "."line 1, column 7

Recorded from each runtime; the wording is in Firefox’s, Safari’s and Python’s sources.

The fraction .5 is common in handwritten notes and accepted in several programming languages. JSON requires 0.5, with an integer part before the point. Here Chrome names the period as an unexpected token and includes the input in its message rather than printing the Unexpected number heading. Firefox calls it an unexpected character, and Python says it was expecting a value at column 7. These are related number-format mistakes, not identical runtime messages.

A zero before the point is valid because the following point introduces the fractional part; the leading-zero ban concerns additional integer digits. The decimal point must also have at least one digit after it, so removing the 5 would not leave a valid number. When a display formatter strips the zero for appearance, keep that formatting in the user interface and use a JSON encoder for the stored or transmitted value.

A plus sign before a positive value

Input

{"n": +1}

Do

  1. Paste the input into the validator.
  2. Press Repair in the editor band.

Result

Corrected number formats

{"n": 1}

Try it in the validator →

What each runtime prints for this input
RuntimeMessage
Chrome 153 · Node.js 26Unexpected token '+', "{"n": +1}" is not valid JSON
Node.js 18 (older V8)Unexpected token + in JSON at position 6
Firefox 156JSON.parse: unexpected character at line 1 column 7 of the JSON data
Safari 26JSON Parse error: Unrecognized token '+'
Python 3.14 jsonExpecting value: line 1 column 7 (char 6)
This siteUnexpected "+"line 1, column 7

Recorded from each runtime; the wording is in Firefox’s, Safari’s and Python’s sources.

JSON permits a minus sign before the integer part, but no leading plus sign. Write 1 where the example has +1; a negative value can be written -1. A sign inside an exponent follows another rule: 1e+2 is valid JSON and means one hundred. Removing all plus signs indiscriminately would therefore edit valid exponent notation as well as the invalid leading sign.

Explicit positive signs often come from a report column showing changes or from string concatenation that prepends a sign to every numeric value. Preserve a signed display label as a string when that label matters, or encode the numeric quantity without its decorative plus. The error in this example is at position 6, column 7, on the plus itself, before the parser can read the digit that follows.

Why the wording depends on the number

Older V8 in Node.js 18 reports the leading-zero case as Unexpected number at position 7, while its fraction and plus cases use Unexpected token with the offending punctuation. Newer V8 retains the number wording here and adds a line and column, but its token messages show a quoted excerpt of the input. Firefox's leading-zero message asks for a comma or brace after an object property; that describes the point where it stopped, rather than a reason to add punctuation inside 012. Read the raw value around the offset before applying a fix suggested by the error's name.

Unexpected number can also describe a valid number placed immediately after another value without a separator. If your digits have ordinary spelling but occur in an array, comparea missing comma after an array element. JSON's numeric grammar serves a shared data format; accepting every language's shortcuts would make the same text ambiguous between readers. Use a decimal integer part, an optional fraction and an optional exponent instead of language-specific prefixes or display conventions.

Checking the corrected values

In the JSON Validator, inspect the underlined value and choose whether it is a quantity or an identifier.Repair reports corrected number formats for all three examples: 012 becomes 12, .5 becomes 0.5, and +1 becomes 1. Those outputs are generated by the repair engine and shown without assuming that a removed zero was unimportant to your application. For a larger document, Fix invalid JSONexplains how to inspect the changes before accepting the repaired text.