Random Number Generator
Pick random numbers in any range — one or many, with or without repeats, whole or decimal.
Numbers that must not come up, separated by commas or spaces.
Uses your browser’s cryptographic random generator.
Draws random numbers between a minimum and a maximum, both included: one number or up to 10,000 at a time, whole or decimal, with or without repeats. It opens on one whole number from 1 to 100. Every number comes from your browser’s cryptographic random generator, and nothing you enter leaves your browser.
How to use it
- Min and Max can be negative and can have up to 100 digits, so a range far larger than a calculator holds still gives every number an equal chance. The button between them swaps the two.
- How many is 1 to 10,000.
- No repeats makes every number in a draw different, as tickets pulled from a hat. A draw cannot ask for more numbers than the range holds: “Only 47 different numbers are available” is the message for 48 numbers from 1 to 50 with three of them excluded.
- Exclude lists numbers that must not come up, separated by commas or spaces. Because commas separate the entries, write 1234 there, not 1,234.
- Decimals adds Decimal places, 1 to 15. Results keep their trailing zeros, so two places gives 0.20, not 0.2.
To pad numbers with zeros, type the range that way: 0000 to 9999 gives four digits every time, such as 0042, which suits a PIN.
Beside a result of several numbers, Order shows them as drawn, ascending or descending, and Copy with chooses whether the copied list is separated by commas, new lines or spaces. Their sum is shown under the list. History keeps the recent draws of this visit; it is held in memory only and is gone when the page is reloaded.
How the numbers are drawn
The browser’s generator (crypto.getRandomValues) supplies random bytes. Turning bytes into a number in a range by taking a remainder would favour the low end slightly, because a range rarely divides evenly into what the bytes can express. The tool instead reads only as many bits as the range needs and draws again whenever the value falls outside it, which is called rejection sampling. Each number in the range is then exactly as likely as any other.
With No repeats, the numbers are chosen by Floyd’s algorithm: one draw per number, with no retrying when a number has already come up. Asking for 9,999 of 10,000 numbers takes no longer than asking for a few, and the chosen numbers are then shuffled so their order is random too.
A decimal number is drawn as a whole number of steps of the chosen precision, so it is exact and both ends can come up.
Examples
Decimals between 0.1 and 0.3
With Decimals, Min 0.1, Max 0.3 and 1 decimal place, the range holds 3 numbers (0.1, 0.2 and 0.3), each with the same chance.
A bound with more places than the result
With Decimals, Min 0.15, Max 0.95 and 1 decimal place, no one-decimal number equals either bound, so each moves inward and the tool says so: “Min 0.15 has more than 1 decimal places, so the range starts at 0.2.” and “Max 0.95 has more than 1 decimal places, so the range ends at 0.9.” A range with nothing in it is refused: “No 1-decimal number lies between 0.11 and 0.19”.
Frequently asked questions
See also
- Wheel Spinner — to pick from names or options instead of numbers.
- Dice Roller — for dice of any size, with totals.
- Password Generator — for random passwords and passphrases from the same generator.