Number of Digits screenshot

Number of Digits

Count the digits in a whole number. The sign is not a digit, leading zeros are not counted, and a non-integer is refused by name.

Privacy First
0 Runs
Updated 2026-11-21
Runs in your browser
No sign-up, no upload

What the number of digits page does

It counts the decimal digits of a whole number. The sign is not a digit, so -1204 and +1204 both have four. The value is read as an integer, so leading zeros are not counted: 007 is seven and has one digit, and 0 also has one.

The count is taken from the normalized decimal string rather than from a JavaScript Number, so no digit is lost to floating-point rounding. That is also why a very long paste still counts exactly; the one limit is 100,000 characters, and a longer input is refused with its length named.

A decimal point, an exponent such as 1e5, a separator such as 1,204 and anything that is not a digit after the optional sign are refused as non-integers. The page names the value, so a typo is easy to find.

How to use it

Paste one whole number into the text box. A leading + or - is accepted.

Press Run. The result prints the digit count and repeats the two rules it applied.

Worked example

Input:

-1204

Output:

Digits: 4

Why it runs in your browser

The counting happens on this page with JavaScript. Nothing you paste is uploaded, and no copy is retained after the page is closed.

Count the decimal digits of a whole number. The sign is not a digit, so -1204 and +1204 both have four.

The value is read as an integer, so leading zeros are not counted: 007 is seven and has one digit, and 0 has one digit too.

The count comes from the normalized decimal string rather than a floating-point number, so a very long paste is still counted exactly up to the 100,000-character cap.

What counts as a digit

Only the decimal digits after the optional sign are counted. A leading plus or minus is accepted and ignored for the count, because it is a sign rather than part of the value.

Leading zeros collapse because the input is read as an integer. 007 is the number seven, so it has one digit; 000 is zero, so it has one. If you need the number of characters as typed, this page is deliberately not that tool.

A decimal point, an exponent, a thousands separator or any other character is refused as a non-integer, and the refusal names the value. The cap is 100,000 characters, which is far past any hand-typed number but keeps the page responsive.

How to use Number of Digits

Paste one whole number into the text box. A leading plus or minus is accepted; spaces around the number are ignored.

Press Run. The result prints the digit count on its own line.

Read the rule line if a result surprises you: it repeats the sign and leading-zero rules so there is no ambiguity about what was counted.

What to Expect

Best for

  • Counting the digits of a long identifier or account number
  • Checking whether a value has the expected number of places

Not ideal for

  • Counting characters as typed, including leading zeros
  • Decimals, fractions or numbers in another base

What this tool keeps

  • The exact length of the normalized decimal string
  • The input's sign, which is reported separately rather than counted

What may need cleanup

  • A leading-zero reading is a different question and needs a different tool
  • A separator such as a comma is refused, so remove it first

Common errors

  • Enter a whole number to count the digits of
  • Not an integer: got "12.5"
  • Too long: the input has more than 100,000 characters

Example use cases

  • Checking an account number's length
  • Teaching place value with a concrete count

Sample input

The integer -1204.

Sample output

Digits: 4, with the sign and leading-zero rules restated.

Who this is for

  • Anyone checking a number's length
  • Students learning place value

Frequently asked questions

Does -1204 have four or five digits?

Four. The minus sign says the value is negative; it is not a decimal digit. The page counts the digits of the value, so the sign is reported separately.

Why does 007 count as one digit?

Because the input is read as an integer, and leading zeros do not change an integer's value. 007 is seven. If you need the character count as typed, use a text-length tool instead.

Can it count a number with 1,000 digits?

Yes, up to 100,000 characters. The count uses the decimal string rather than a JavaScript number, so no digits are lost to rounding.

Developer program

Build custom tools for your store

Join the SDK program to create useful ecommerce utilities for your store.