Random number generator
This random number generator picks whole numbers in any range you set: one number, or up to 10,000 at once, with or without repeats, each equally likely.
Your numbers
- –
How to use it
- Enter the lowest and highest number, or tap a common range such as 1–10 or 1–100.
- Choose how many numbers you need, and whether a number may come up twice.
- Press Generate, then copy the numbers if you need them elsewhere.
How a fair random number is picked
For a range from min to max the generator counts the values (max − min + 1), draws a 32-bit number from crypto.getRandomValues and maps it onto that count. A plain remainder would be slightly unfair, because 2³² is not a multiple of most range sizes: 2³² divided by 100 leaves 96, so with 1 to 100 the first 96 numbers would each get one extra way to come up. The generator throws away values from that uneven top slice and draws again. Every number in your range then has exactly the same chance, 1 in 100 for 1 to 100.
Ranges wider than 2³² values (about 4.3 billion) combine two draws into a 53-bit number, the largest whole number JavaScript stores exactly, with the same rejection step. That is why both ends of the range are limited to 15 digits.
MDN’s reference says browsers seed this generator with a value of enough entropy and that its output is suitable for cryptographic use, unlike Math.random. A result cannot be worked out from the ones before it.
With repeats or without
With No repeats off, every number is drawn from the full range, so the same value can come up again. That happens more often than people expect: draw 10 numbers from 1 to 100 and the chance that at least two of them match is about 37%. Draw 5 from 1 to 10 and it is about 70%.
With No repeats on, numbers are drawn without replacement, like balls out of a bingo drum. For ranges of up to 100,000 values the generator shuffles the whole range with the Fisher–Yates method and takes the first numbers; for larger ranges it draws and skips any number it already has. Either way every set of numbers is equally likely. You can draw at most as many numbers as the range holds: 49 from 1 to 49 gives all of them in random order, and 50 is refused.
Tick Sort smallest first to list the results in order, which helps when you check them against tickets.
Examples
The ranges and settings people ask for most:
| Range | How many | Use | Chance |
|---|---|---|---|
| 1 to 10 | 1 | Pick a number game, choosing a page or a task | 10% per number |
| 1 to 100 | 1 | Numbered raffle tickets, percentages | 1% per number |
| 1 to 6 | 1 | A die roll, as text | 16.7% per number |
| 0 to 9 | 4, repeats on | A random four-digit code | 1 in 10,000 per code |
| 1 to 49 | 6, no repeats | A lottery-style pick | 1 in 13,983,816 per set |
| 1 to 30 | 30, no repeats | Seating or presenting order for a class of 30 | every order equally likely |
Drawing a raffle winner by number
Number the tickets, enter 1 and the highest ticket number, and press Generate. For first, second and third prize, set How many numbers to 3 with No repeats on and leave sorting off: the first number shown wins first prize. Saying the range and settings out loud before you press the button, or drawing on a projector, lets everyone see that the draw was not run twice.
Prefer a wheel? The spin the wheel page has a 1 to 10 preset and takes any numbers, one per line. For dice with notation such as 2d6+3, use the dice roller; to draw names instead of numbers, the random name picker.
Related tools
Questions people ask
How do I generate a random number between 1 and 100?
Tap the 1–100 button. It fills the range and generates a number straight away. Press Generate for another.
How do I get random numbers with no repeats?
Leave No repeats on and set How many numbers. Every number drawn is different, up to the size of the range.
Why did the same number come up twice?
No repeats was off, so each number was drawn from the whole range. In 10 draws from 1 to 100 a repeat happens about 37% of the time. Turn No repeats on to rule it out.
Can I use negative numbers?
Yes. Any whole numbers work, for example −50 to 50. Decimals are rounded inwards to the nearest whole number in the range.
How many numbers can I generate at once?
Up to 10,000 per press. With No repeats on, the count cannot be larger than the range: 1 to 100 allows at most 100.
Is it random enough for a raffle or a lottery-style draw?
The numbers come from your browser’s cryptographic random generator, the same source used for encryption keys. For a draw with legal rules, follow the rules on who must run and witness it.