Random 9 Digit Number: How to Generate One

How-to basics · Updated November 23, 2026

A random 9-digit number is any integer from 100,000,000 to 999,999,999, inclusive, where each digit is chosen independently and uniformly. You can generate one manually, with a calculator, or using a simple spreadsheet formula like =RANDBETWEEN(100000000,999999999) in Excel.

What Makes a Number Truly Random?

Randomness means each possible outcome has an equal chance of occurring, and past outcomes do not influence future ones. For a 9-digit number, there are 900,000,000 possible values (999,999,999 − 100,000,000 + 1). A truly random generator ensures every one of those values is equally likely. However, most everyday tools—like a calculator’s RAND function—use a pseudo-random number generator (PRNG). PRNGs start from a seed value and apply a mathematical algorithm to produce a sequence that appears random but is actually deterministic. For most purposes (lottery picks, password hints, game seeds), a PRNG is perfectly fine. For cryptographic security (e.g., generating an encryption key), you need a hardware-based true random generator, which uses physical phenomena like electronic noise.

How to Generate a Random 9-Digit Number in Excel

In Microsoft Excel (Microsoft 365 or Excel 2021), the simplest method is the RANDBETWEEN function. It returns a random integer between a bottom and top value you specify.

  • Type =RANDBETWEEN(100000000,999999999) into any cell and press Enter.
  • Each time the worksheet recalculates (e.g., pressing F9 or editing any cell), a new number appears.
  • To keep a fixed number, copy the cell and paste as values (right-click > Paste Special > Values).

If you need multiple numbers, drag the fill handle down or across. For a dynamic array that spills, you can use =RANDARRAY(10,1,100000000,999999999,TRUE) in Excel 365, which returns 10 random integers in a column. Note: RANDARRAY requires Microsoft 365 or Excel 2021; it does not exist in older versions.

For a more manual approach, you can combine RAND() with arithmetic: =INT(RAND()*900000000)+100000000. This works in any Excel version because RAND() returns a decimal between 0 and 1. Multiply by 900,000,000 (the total count of 9-digit numbers), take the integer part, and add 100,000,000 to shift the range.

Using Google Sheets or Other Tools

In Google Sheets, the same RANDBETWEEN function works identically: type =RANDBETWEEN(100000000,999999999) in a cell. Google Sheets also has RANDARRAY but with a different argument order: =RANDARRAY(rows, columns, min, max, whole_number). For example, =RANDARRAY(5,1,100000000,999999999,TRUE) gives five random integers. On a physical calculator, look for a random integer function (often labeled RANDI or RANDOM). On a smartphone, you can use a search engine: type “random number generator” and set the range from 100000000 to 999999999. Many websites also offer free generators with options to exclude repeats or produce a list.

How to Choose a Random 9-Digit Number Manually

If you don’t have a tool, you can generate one manually using dice or a deck of cards. For each of the 9 positions, you need a digit 0-9, but the first digit cannot be 0 (otherwise it would be an 8-digit number). One method:

  1. Roll a 10-sided die (or draw a card from a deck with 10 cards labeled 0-9) for the first digit. If you get 0, reroll until you get 1-9.
  2. For the remaining 8 digits, roll the die or draw a card each time, allowing 0.
  3. Write the digits in sequence to form your 9-digit number.

This gives a uniform distribution over all valid 9-digit numbers, assuming your die or cards are fair. A common mistake is to generate a random number from 0 to 999,999,999 and then pad with leading zeros—that would produce numbers like 000123456, which is not a 9-digit number because it has fewer than 9 digits. Always ensure the first digit is non-zero.

Common Problems and Misconceptions

One frequent issue is that RANDBETWEEN in Excel recalculates every time the workbook changes, which can be annoying if you want to keep a number. Solution: copy and paste as values. Another misconception: a number like 123456789 seems “not random” to humans, but it is just as likely as any other. Our brains are bad at recognizing randomness—we expect patterns. Also, some people think that generating a random number twice will give the same result if you use the same seed. That’s true for PRNGs, but most applications use a time-based seed, so you get different numbers each time.

Another problem: when generating a list of random 9-digit numbers, duplicates can occur. If you need unique numbers (e.g., for ID codes), you must check for duplicates or use a method that ensures uniqueness, such as starting with a sequential list and shuffling it. In Excel, you can use =SORTBY(SEQUENCE(900000000),RANDARRAY(900000000)) but that’s impractical for huge lists; for smaller lists, generate more than you need and remove duplicates.

Safety and Security Considerations

Random 9-digit numbers are often used for PINs, verification codes, or temporary passwords. However, a 9-digit number has only 900 million possibilities, which is relatively small for security purposes. A determined attacker with a computer can brute-force all combinations in seconds to minutes. For security-sensitive uses like two-factor authentication codes, always use a dedicated secure generator that follows industry standards (e.g., RFC 6238 for TOTP). Do not use a simple random number from a spreadsheet for passwords or encryption keys. Also, if you generate a number for a lottery or contest, ensure the method is truly random and unbiased; using a PRNG with a fixed seed could be predictable. For official draws, use a certified random number generator.

Alternatives to Random 9-Digit Numbers

If you need a unique identifier, consider using a UUID (universally unique identifier) instead. A standard UUID is 128 bits, often displayed as 32 hexadecimal digits, and is practically unique. In Excel, you can generate a UUID with =LOWER(CONCATENATE(DEC2HEX(RANDBETWEEN(0,4294967295),8),"-",DEC2HEX(RANDBETWEEN(0,65535),4),"-","4",DEC2HEX(RANDBETWEEN(0,4095),3),"-",DEC2HEX(RANDBETWEEN(16384,20479),4),"-",DEC2HEX(RANDBETWEEN(0,4294967295),8),DEC2HEX(RANDBETWEEN(0,65535),4)))—but that’s complex and not a true UUID. Alternatively, use a random alphanumeric string, which has a much larger space. For example, a 9-character string using uppercase letters and digits (36 possible characters) has 36^9 ≈ 10^14 possibilities, much larger than 10^9. If you need a human-friendly number, a 9-digit number is fine for non-security purposes like order numbers.

Frequently Asked Questions

How do I generate a random 9-digit number in Python?

In Python, you can use the random module: import random; print(random.randint(100000000, 999999999)). This uses the Mersenne Twister PRNG, which is not cryptographically secure. For security, use secrets.randbelow(900000000) + 100000000.

Can I get a random 9-digit number with no repeating digits?

Yes, but it’s not a uniform random number from the full range. To get a number with all digits distinct, you’d need to permute the digits 0-9 and pick a 9-digit sequence where the first digit is not zero. The count is 9 * 9! (9 choices for first digit, then 9! for the rest) = 9 * 362,880 = 3,265,920 possibilities. You can generate one by shuffling the digits 0-9, taking the first 9, and ensuring the first isn’t 0; if it is, swap with the first non-zero.

What is the largest 9-digit number?

The largest 9-digit number is 999,999,999. The smallest is 100,000,000, because 099,999,999 is an 8-digit number when leading zeros are not counted.

Why does Excel’s RANDBETWEEN change every time I open the file?

Because RANDBETWEEN is a volatile function—it recalculates whenever Excel recalculates, which happens on open, on edit, and on F9. To freeze the value, copy the cell and use Paste Special > Values to replace the formula with the static number.

Is a random 9-digit number safe for a password?

No. A 9-digit number has only 900 million combinations, which can be brute-forced quickly. Use a longer password with letters, numbers, and symbols, or a passphrase. For two-factor authentication, use a TOTP app that generates 6-digit codes with a time-based secret.

Related

Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.

More in How-to basics

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.