Works on this device
Random Number Generator
Choose a range, for example 1 to 100, and get one random number or a whole list. You can stop repeats, ask for decimals, make a code with a set count of digits, or make lottery-style lines. The numbers are made on your device with the secure random generator of your browser.
Choose your settings
Check these values
The numbers are made in this browser. They are not sent to a server.
Your numbers will show here
Choose Generate to make them.
Your result
How it was worked out
How to use the random number generator
- Choose what you want to make, for example Random numbers in a range.
- Enter the smallest and the largest number. Both can come up.
- Enter how many numbers you want. Tick No repeats when each number may come up only once.
- Choose Generate. Choose it again for new numbers.
- Use Copy numbers to paste the list somewhere else, Download list to save it as a file, or Print.
What each option does
- Random numbers in a range gives one number or a list of up to 10,000. Under More options you can sort the list, keep only even or odd numbers, and leave out numbers you do not want.
- Decimal places changes the step between two possible numbers. With 2 decimal places, the range 0 to 1 holds 101 numbers: 0.00, 0.01, 0.02 and so on up to 1.00. Each of them has the same chance.
- Repeatable numbers from a seed gives the same list every time for the same seed and settings. It is useful for examples, lessons and tests. It is not secure.
- Number with a set count of digits makes a code such as a 4-digit PIN or a 6-digit number. You choose whether it may start with 0.
- Lottery-style lines picks different numbers for each line, for example 6 numbers from 1 to 49. You can add extra numbers from a second set, such as a bonus ball.
- All numbers from A to B in random order mixes a whole range, for example 0 to 9 for a squares grid or ticket numbers 1 to 200 for the order of a draw.
- Pick from my own list of numbers picks from the numbers you type or paste.
How the numbers are made
Every choice is a pick from a set count of possible values, and each value has the same chance. The tool asks your browser for random bytes from its secure generator (the Web Crypto function crypto.getRandomValues). This generator is made for security uses such as encryption keys. It is a cryptographic generator. It is not a quantum or atmospheric source.
To pick one of n values, the tool takes just enough whole bytes to hold n − 1, reads them as one number and keeps only the bits it needs. If the value is n or more, it throws the bytes away and takes new ones. This is called rejection sampling. A simpler method, the remainder after dividing by n, would make some numbers come up a little more often. The tool does not use it.
With No repeats, a number that came up is taken out of the set before the next pick. Sorting happens after all numbers are drawn, so it does not change which numbers came up.
The tool never uses Math.random. If your browser has no secure generator, the tool stops and tells you. It does not fall back to a weaker one.
Worked examples
A range of 1 to 100 holds 100 possible numbers. One byte gives 256 values, and the tool keeps 7 bits of it, which is 0 to 127. Values of 100 to 127 are thrown away, and the others give the numbers 1 to 100. Each number has a chance of exactly 1 in 100.
For 6 numbers from 1 to 49 there are 13,983,816 different lines. Each line has the same chance of 1 in 13,983,816, also a line such as 1, 2, 3, 4, 5, 6.
A seed always gives the same list. With the seed 0, the range 0 to 255 and 11 numbers, the list is 60, 71, 209, 170, 98, 159, 87, 163, 129, 148, 203. You can try this in Repeatable numbers from a seed.
The seed method
The seed mode uses a simple, well-known rule called a linear congruential generator, here named LCG32. It keeps one number, the state, which starts as your seed. For each random byte, the new state is (1664525 × state + 1013904223) mod 2^32, and the byte is the top 8 bits of the state. The bytes are then turned into numbers in the same way as in the other modes.
A seed is a whole number from 0 to 4,294,967,295, so there are only about 4.3 billion different lists. Anyone who knows the seed and the settings can make the same list. Use the seed mode when a list must be repeated, and never for passwords, prizes or anything secret. Other programs use other rules, so the same seed gives other numbers there.
Limits you should know
- A bound can have up to 30 digits before the decimal point, so ranges far above 2^53 (about 9 million billion) work and every digit is exact. You can use up to 6 decimal places.
- One list can hold up to 10,000 numbers. The table on the page shows the first 500, and the copied text and the file hold all of them.
- Every possible number has the same chance. Weighted numbers and bell-curve (normal) numbers are not offered.
- A random pick cannot predict a lottery, and no method makes a win more likely. Check the rules of your lottery, because they can change.
- This page is not a certified or witnessed draw. For a prize draw with legal rules, use a method that the rules accept.
- A code or PIN made here is shown on your screen and goes to your clipboard when you copy it. The page does not save or send it. For passwords, use the Password Generator.
- The tool shows numbers only. It has no spinning wheel, sound, voice or timer.