Random Number Generator

Enter a lower and an upper limit to pick a random number in that range.

Updated

Repeats
Enter to generate Esc to clear

Random Number Generator

Our Random Number Generator picks a number from any range you choose, with both limits included and every number equally likely. Generate one number or a list of up to 1,000, with or without repeats, including negative and decimal numbers. Use it to pick a winner, choose a student, roll dice, draw lottery numbers or create test data. The numbers come from your browser’s cryptographic random generator and never leave your device.

Quick answer

To get a random number, enter the lowest and highest number you want and press Generate. Every whole number in the range has the same chance: 1 to 100 gives each number a 1 in 100 chance, and 1 to 6 works like a die.

  • Limits: both the lower and upper limit can come up
  • Chance of each number: 1 ÷ (max − min + 1)
  • No repeats: every number in the list is different, like a lottery draw
  • Decimals: type 0 to 1.00 for numbers with two decimal places

What Is a Random Number Generator?

A random number generator (RNG) produces numbers with no pattern, so the next one cannot be predicted from the ones before. A fair generator also gives every allowed number the same chance, which is called a uniform distribution. Dice, coins and lottery machines are physical random number generators; this page does the same job in your browser for any range.

Computers usually make pseudo-random numbers: a formula turns a starting value (the seed) into a long sequence that looks random. Simple generators such as Math.random are fine for games but can in principle be predicted. Cryptographically secure generators, which this page uses, are seeded from unpredictable data gathered by your device and are safe even for passwords and encryption keys.

How Random Numbers Are Picked

To pick a whole number from a to b, count the possible numbers and take a random position in that list:

Possible numbers n = b − a + 1
Result R = a + (random whole number from 0 to n − 1)
Chance of each 1 ÷ n

Example, 10 to 27: n = 27 − 10 + 1 = 18, each has a 1 in 18 chance

Done carelessly, this step favours some numbers (called modulo bias). The generator avoids it by throwing away the few raw values that would tip the balance and drawing again, so every number in the range is exactly as likely. For decimals, the range is split into steps (0.1 for one decimal place) and one step is picked the same way, so 1.5 to 9.8 has 84 equally likely values.

Use and settingsChance
Roll a die
1 to 6
1 in 6
Flip a coin
1 to 2
1 in 2
Pick a percentage
1 to 100
1 in 100
Choose 1 of 27 students
1 to 27
1 in 27
6 from 49 lottery
1 to 49, 6, no repeats
1 in 13,983,816
PIN code
0 to 9, 4, repeats
1 in 10,000

Picking a winner. Give each of 10 entries a number from 1 to 10 and generate one number. If 6 comes up, entry 6 wins, and everyone had the same 1 in 10 chance. Sharing the screen while you press Generate keeps the draw transparent.

Probability and Repeats

Each draw is independent: after a 6 on a die, the next roll still has a 1 in 6 chance of being 6. Two sixes in a row happen 1 time in 36. Repeats in a list are more common than intuition suggests:

Draw (repeats allowed)Chance of a repeat
10 numbers from 1 to 10037.2%
23 birthdays (1 to 365)50.7%
38 numbers from 1 to 1,00050.9%
At least one 6 in 4 rolls51.8%

If every number has to be different, choose “No repeats”.

Random Numbers in Excel and Code

ToolWhole number from 1 to 100
Excel / Sheets=RANDBETWEEN(1, 100)
Pythonrandom.randint(1, 100)
Python, no repeatsrandom.sample(range(1, 101), 6)
Python, secure1 + secrets.randbelow(100)
JavaScriptMath.floor(Math.random() * 100) + 1

Watch the limits: Python’s randint includes both ends, but range(1, 101) stops at 100, and Math.random() never returns 1, which is why the JavaScript version adds 1 after rounding down.

Common Mistakes

  • The gambler’s fallacy. A number that has not come up for a while is not “due”; every draw starts fresh.
  • Off-by-one ranges. 1 to 10 has 10 numbers, but 0 to 10 has 11.
  • Rounding a random decimal. Rounding a value from 1 to 10 makes 1 and 10 half as likely as the others; pick whole numbers directly instead.
  • Using Math.random for secrets. For passwords, tokens or keys, use a cryptographic generator such as crypto.getRandomValues or Python’s secrets.

Key Terms

Range
All the numbers from the lower limit to the upper limit, both included.
Uniform
A uniform distribution: every possible number has the same chance.
Pseudo-random
Produced by a formula from a seed; looks random but is reproducible from the seed.
CSPRNG
Cryptographically secure random number generator: it cannot be predicted even by someone who has seen earlier outputs.
Replacement
Drawing with replacement allows repeats and without replacement does not, like putting a drawn ball back or keeping it out.
Modulo bias
A slight preference for some numbers caused by careless scaling, avoided here.

How to Use the Random Number Generator

  1. Set the range. Type the smallest number in “Lower limit (min)” and the largest in “Upper limit (max)”, for example 1 and 100. Both limits can come up. Type decimals such as 1.5 to get decimal results.
  2. Choose how many. Leave “How many numbers” at 1, tap 5 or 10, or type up to 1,000. Pick “No repeats” if every number must be different, like drawing names from a hat.
  3. Generate. A number appears as soon as both limits are filled in. Press Generate (or Enter) for a new draw. The line underneath shows the chance of each result, for example 1 in 100 chance.
  4. Copy the result. Press Copy to copy the number, or the whole list separated by commas. Press Clear or Esc to start again.

Example: enter 1 and 49, set “How many numbers” to 6 and choose “No repeats” to get six different lottery numbers; the note shows the 1 in 13,983,816 odds.

Who Can Use This Generator?

TeachersChoosing students, groups and quiz questions fairly
Giveaways and RafflesDrawing winners openly and without bias
GamesDice, coin flips, card numbers and turn order
Researchers and DevelopersRandom samples, test data and simulations

Frequently Asked Questions (FAQs)

How do I generate a random number between 1 and 100?

Enter 1 as the lower limit and 100 as the upper limit. A number appears straight away, and each press of Generate gives a new one. Both 1 and 100 can come up, and every number has the same 1 in 100 chance.

Is this random number generator truly random?

It uses your browser’s cryptographic random generator (crypto.getRandomValues), the same kind used to create encryption keys. It is seeded from unpredictable data collected by your device, so results cannot be guessed, and each draw is independent of the last. Strictly speaking it is a cryptographically secure pseudo-random generator; “true” random generators measure physical noise, but for games, draws and sampling the two are indistinguishable.

Are the lower and upper limits included?

Yes, both limits are included. With 10 and 27 the result can be 10, 27 or any whole number in between, 18 possible numbers in all.

How do I generate several numbers without repeats?

Set “How many numbers” and choose “No repeats”. Every number in the list is then different, like drawing balls from a lottery machine. You can ask for at most as many numbers as the range holds: 1 to 10 has only 10 different numbers.

Can I generate negative or decimal numbers?

Yes. Negative limits work, for example −5 to 5. For decimals, type the limits with the decimal places you want: 1.5 to 9.8 gives numbers like 4.7 (one decimal place), and 0 to 1.00 gives numbers like 0.37.

What are the odds of winning a 6 from 49 lottery?

There are C(49, 6) = 13,983,816 possible sets of 6 numbers, so one ticket has a 1 in 13,983,816 chance of matching all six. Generate 6 numbers from 1 to 49 with “No repeats” to pick a line; the note under the result shows these odds.

Why do repeats come up so often?

Repeats are more likely than people expect. Drawing 10 numbers from 1 to 100 gives at least one repeat about 37% of the time, and in a group of 23 people the chance that two share a birthday is just over 50%. It is the same maths, known as the birthday problem.

How do I generate a random number in Excel?

=RANDBETWEEN(1, 100) gives a whole number from 1 to 100, both included. =RAND() gives a decimal from 0 up to (not including) 1. Both change every time the sheet recalculates; copy and paste as values to keep a result.

Can I use it to roll dice or flip a coin?

Yes. For a die use 1 to 6, for two dice set “How many” to 2 with repeats allowed. For a coin use 1 to 2 and call 1 heads and 2 tails. To pick a winner, number the entries and generate one number in that range.

Is the Random Number Generator free?

Yes. It is completely free, needs no sign-up, and runs in your browser, so the numbers are never sent anywhere.

Try our Random Number Generator to pick fair random numbers in any range.