Random number generator

Pick one or more random whole numbers between any minimum and maximum, with or without repeats.

Runs in your browser. Nothing is uploaded.

Order
?

Quick:

How to use it

  1. Set Min and Max. Both are included, so 1 to 10 can give 1 or 10.
  2. Set How many numbers you want. Leave Allow repeats off if each number may only come up once, as in a raffle.
  3. Press Generate (or Enter). Choose an order if you want the results sorted.
  4. Press Copy to copy the results, separated by commas.

Why the numbers are fair

Computers produce random bits, not random numbers in your range, so they have to be converted. The common shortcut, taking the remainder after division, is slightly unfair. A 32-bit random value has 4,294,967,296 possible results, which does not divide evenly by 6, so a remainder-based "1 to 6" gives 1 to 4 a tiny bit more often than 5 and 6.

This generator uses rejection sampling instead: it throws away the few raw values at the top that would cause the imbalance and draws again. Every number in your range then has exactly the same chance. For very wide ranges it uses 53 random bits, so it stays fair all the way to ±9,007,199,254,740,991.

Drawing numbers without repeats

With Allow repeats off, each number can come up only once, like balls drawn from a bag. Use it for raffles (tickets 1 to 500, draw 3 winners), assigning seats or picking lottery-style numbers:

  • Powerball: 5 numbers from 1 to 69, then 1 number from 1 to 26.
  • Mega Millions: 5 numbers from 1 to 70, then 1 number from 1 to 24.
  • EuroMillions: 5 numbers from 1 to 50, then 2 from 1 to 12.

A random pick has the same odds of winning as any other set of numbers, but you are less likely to share a jackpot, because people who choose their own numbers favor birthdays (1 to 31).

Questions

How random are the numbers?
They come from your browser's cryptographic random number generator (crypto.getRandomValues), which is seeded by your operating system and is used for passwords and encryption keys. Each number in the range is equally likely, and earlier results tell you nothing about the next one.
Can I use negative numbers?
Yes. Min and max can be any whole numbers, including negatives, for example −50 to 50.
Can it generate decimals?
No, it picks whole numbers only. For one decimal place, pick from 0 to 100 and divide the result by 10 in your head: 37 becomes 3.7.
How many numbers can I generate at once?
Up to 10,000. Without repeats you cannot ask for more numbers than the range contains: 1 to 10 has only 10 different numbers.
Are my settings saved?
Your last min, max and options are remembered in this browser so they are ready next time. Nothing is sent to a server.