Maths tool · Free · No sign-up
Random Number Generator
To pick a random number, set the lowest and highest values and press Generate: each whole number in the range is equally likely. This generator draws from the browser’s cryptographic source, crypto.getRandomValues, and rejects draws that would bias the range, so 1 to 100 really is 1 in 100 each. It can draw many without repeats.
Nothing is sent anywhere.
| Fact | Value |
|---|---|
| Numbers in the range | 100 |
| Chance of any one number on a draw | 1 in 100 |
| Random source | crypto.getRandomValues, 64 bits a draw, rejection sampling |
Whole numbers between −1015 and 1015, up to 1,000 at a time. Press Enter in any box to draw again. The numbers are made in this browser by its cryptographic random source and kept there; nothing is sent anywhere.
Choose the range and how many numbers you want, tick No repeats for a raffle or a sample, and press Generate. The odds of the draw are shown beside it: one number, a repeat if repeats were allowed, and one exact set.
A random number generator picks numbers so that each one in the range is equally likely and none can be predicted from the ones before. Drawing without repeats is drawing without replacement, as from a hat.
- No sign-up
- Nothing sent anywhere
- Cryptographic source
- No modulo bias
Key facts
| Detail | Answer |
|---|---|
| Range | Any whole numbers from −1015 to 1015 |
| How many | 1 to 1,000 a draw, with or without repeats |
| Random source | crypto.getRandomValues, the Web Cryptography API; never Math.random |
| Range mapping | Rejection sampling on 64-bit draws, so no modulo bias |
| No repeats | Partial Fisher–Yates shuffle or redraw; every set equally likely |
| Where your numbers are kept | This browser only |
How to generate random numbers without repeats
Set the range and the count, then draw.
Set the range
The lowest and highest numbers you want, such as 1 and 100.
Choose how many
From 1 to 1,000. The table shows the chance of a repeat if repeats were allowed.
Tick No repeats if each number may come out once
As for raffle tickets or choosing people.
Tick Sort if you want them in order
Useful for long lists; the draw is the same.
Press Generate
Or press Enter in any box. Draw again as often as you like.
Copy the result
The numbers copy one per line.
Who uses a random number generator
Anyone who needs a choice that nobody made.
Raffles and prize draws
Ticket numbers without repeats, odds shown.
Teachers
Picking pupils or groups fairly.
Researchers and surveyors
Choosing a random sample of forms or households.
Games
Turn order and numbered choices; for dice with the odds of every total, the dice roller, or the 3D dice roller to watch them tumble.
Event organisers
A random running order.
Anyone deciding
1 to 2 settles it, or ask the yes or no generator, or draw a card with the one card tarot.
Modulo bias, and how this generator avoids it
A computer’s random source gives random bits, not a number from 1 to 100. Turning bits into a range is where most generators go slightly wrong. The usual shortcut takes the random value and keeps the remainder after dividing by the size of the range. Unless the number of possible values divides evenly by the range size, some remainders come up more often than others. That unevenness is called modulo bias, and it is usually the cause of an unfair pick, not the choice between Math.random and crypto.getRandomValues, which the guide to that choice compares.
The effect is easiest to see with a small source. One random byte has 256 equally likely values, 0 to 255. Take the remainder after dividing by 100 and the results 0 to 55 each have three ways to happen (for 0: 0, 100 and 200), while 56 to 99 have only two, because 256 = 2 × 100 + 56.
| Results | Ways out of 256 | Chance | Compared with fair (1 in 100) |
|---|---|---|---|
| 0 to 55 | 3 | 1.17% | 17% too likely |
| 56 to 99 | 2 | 0.78% | 22% too unlikely |
The fix is rejection sampling: find the largest multiple of the range size that fits in the source, and if a draw lands above it, throw it away and draw again. In the byte example, anything from 200 to 255 is redrawn, and every result from 0 to 99 is left with exactly two ways to happen. This generator does the same with 64-bit draws: for a range of n numbers it rejects any draw at or above 264 minus (264 mod n). With 64 bits a rejection is extremely rare, and the table under the generator counts them anyway.
The bits come from crypto.getRandomValues. The W3C’s Web Cryptography API specification says the method “generates cryptographically strong random values”, and MDN’s reference describes Math.random, which many generators use, as “a non-cryptographic source of random numbers”. This page never calls Math.random.
No repeats, and the odds of a set
With “No repeats” ticked, each number can come out once, like a raffle ticket drawn from a hat and not put back. For ranges up to 100,000 numbers the generator shuffles the whole range with a partial Fisher–Yates shuffle, drawing each position with the same unbiased method; for larger ranges it draws and simply draws again on a duplicate. Both make every possible set equally likely.
The table under the generator gives the odds of one exact set when the order does not matter, which is how lotteries are counted: the number of ways to choose k numbers from n.
| Draw | Possible sets | Odds of one set |
|---|---|---|
| 3 from 1–10 | 120 | 1 in 120 |
| 6 from 1–49 | 13,983,816 | 1 in 13,983,816 |
| 5 from 1–69 | 11,238,513 | 1 in 11,238,513 |
| 6 from 1–59 | 45,057,474 | 1 in 45,057,474 |
These are the odds of matching a set chosen in advance, for the draw alone; a real lottery may add a bonus ball or other rules, which change its published odds.
How likely is a repeat? The birthday problem
When repeats are allowed, a repeat comes sooner than most people expect. In a room of 23 people the chance that two share a birthday is just over a half, even though there are 365 possible birthdays. The same arithmetic applies to any draw with repeats: the chance of no repeat is (1 − 1/n) × (1 − 2/n) × … for each number after the first, and the chance of at least one repeat is 1 minus that.
| Draw | Chance of a repeat |
|---|---|
| 3 rolls of a die (1–6) | 44.44% |
| 4 numbers from 1–10 | 49.6% |
| 10 numbers from 1–100 | 37.18% |
| 13 numbers from 1–100 | 55.72% |
| 23 birthdays (1–365) | 50.73% |
| 38 numbers from 1–1,000 | 50.93% |
| 50 birthdays (1–365) | 97.04% |
The generator shows this figure for any draw of more than one number, so you can see whether “repeats allowed” is likely to give you a repeat before you press Generate. If a repeat would spoil the draw, such as picking raffle winners or pupils, tick No repeats.
Settings for fair draws: raffles, classrooms and samples
A fair draw is only fair if everyone agrees how it was made. Set the range to match what you are choosing from, decide on repeats before you press Generate, and keep the result: the numbers stay on the page and can be copied.
| Draw | From | To | How many | No repeats |
|---|---|---|---|---|
| A raffle with 250 tickets, 3 prizes | 1 | 250 | 3 | Yes |
| Pick 5 pupils from a register of 28 | 1 | 28 | 5 | Yes |
| Roll two dice | 1 | 6 | 2 | No |
| Toss a coin 10 times (0 tails, 1 heads) | 0 | 1 | 10 | No |
| A random sample of 40 from 1,200 forms | 1 | 1200 | 40 | Yes |
| Shuffle a running order of 12 acts | 1 | 12 | 12 | Yes |
Random samples are the serious use. Choosing which survey forms or households to follow up by a draw, rather than by hand, keeps the sample from leaning towards the convenient ones; the guide to how many people to survey covers how large the sample should be. For random words rather than numbers there is the random word generator, which uses the same unbiased method. To toss a coin with the sides named, 1 to 100 coins at once and the odds of every streak, use the coin flip, or to call a side first and score the guess, guess heads or tails; to roll dice, the dice roller; to pick names rather than numbers, the random picker.
What this generator does not do
This generator draws whole numbers for games, raffles, classrooms and samples. It does not make passwords or encryption keys: the W3C specification itself says “do not generate keys using the getRandomValues method” and points to its key-generation method instead, and a password is better made by a password manager. It does not draw decimals, weighted numbers or numbers outside −1015 to 1015, and it keeps no record of past draws beyond the last one in this browser.
| It does | It does not |
|---|---|
| Whole numbers from a cryptographic source, with no modulo bias | Use Math.random |
| 1 to 1,000 numbers, with or without repeats, sorted if you like | Draw decimals or weighted numbers |
| Show the odds of a number, a repeat and a set | Make passwords or encryption keys |
| Keep the last draw in this browser | Send the numbers anywhere |
This generator or a typical random number generator
What this page adds to a typical random number generator.
| This generator | A typical generator | |
|---|---|---|
| Random source | crypto.getRandomValues, named | Usually Math.random, unnamed |
| Range mapping | Rejection sampling, no modulo bias | Remainder or rounding, not stated |
| No repeats | Fisher–Yates or redraw, every set equally likely | Often available |
| Odds shown | One number, a repeat, an exact set | No |
| Range | −1015 to 1015, exact | Often up to 253 or less |
| Your numbers leave the browser | Never | Varies |
More random tools
Every random tool on the site runs in your browser, needs no sign-up, and sends nothing anywhere.
All 6 random tools, by category: Coins & yes or no (2) · Dice (2) · Cards & draws (1) · Numbers & picks (1)
Frequently asked questions
How do I generate random numbers without repeats?
Set the range and how many numbers you want, tick No repeats and press Generate. Each number can then come out only once, as when tickets are drawn from a hat. You cannot ask for more numbers than the range holds: 11 different numbers from 1 to 10 is impossible, and the generator says so.
Is this random number generator truly random?
It uses the browser’s cryptographic random source, crypto.getRandomValues, which the W3C specification requires to give cryptographically strong random values. That is unpredictable for any practical purpose, though it is not a physical device such as dice or a radioactive source.
What is modulo bias?
The unevenness that comes from turning random bits into a range by taking a remainder. A byte has 256 values; taking the remainder after dividing by 100 makes 0 to 55 come up 3 times in 256 and 56 to 99 only twice. This generator avoids it by redrawing any value above the largest multiple of the range size.
How do I pick a random number between 1 and 100?
Leave the range at 1 to 100 and the count at 1, and press Generate. Every whole number from 1 to 100, both ends included, has the same 1 in 100 chance on each draw. Press Generate again for another, or Enter in any box.
Can I use this for a raffle or lottery numbers?
Yes. Number the tickets from 1, set the range to the number of tickets, the count to the number of prizes, and tick No repeats. For lottery-style numbers, such as 6 from 1 to 49, the table gives the odds of one exact set, 1 in 13,983,816.
Why did I get the same number twice?
Because repeats were allowed, and repeats are more common than they feel. Drawing 10 numbers from 1 to 100 with repeats gives at least one repeat 37% of the time; 23 birthdays share one about 51% of the time. Tick No repeats if a repeat would spoil the draw.
Does the generator include the minimum and maximum?
Yes. Both ends are included, so 1 to 6 works as a die and 0 to 1 as a coin. The table shows how many numbers are in the range: 6 for 1 to 6, 101 for 0 to 100.
Can I generate negative or very large random numbers?
Yes, any whole numbers from minus one quadrillion to one quadrillion (1015). The generator works in exact 64-bit draws, so large ranges stay unbiased and every number is written out in full. A range that wide makes a repeat very unlikely, and the table shows how unlikely.
Related guides
Longer answers to the questions behind the numbers.
- Random
Math.random vs crypto.getRandomValues
What each function promises in the spec, why Math.random is not biased but is predictable, why getRandomValues is itself a seeded generator, and the modulo mistake that makes picks unfair with either.
- Surveys
How many people do you need to survey?
Why 385 answers a city and 45 answers a club, and the margin each sample size buys.
- Dice
How to test whether a die is fair
The chi-square test in four steps with a worked example, the 5% limit for a d4 to a d100, and the part most guides skip, how many rolls it takes to catch a die that really is loaded.
- Ecology
Quadrat sampling, from the count to the population estimate
The edge rule the field manuals recommend, a population estimate worked with its error, the sample-size formula behind "how many quadrats", and cover scales.