Random number generator
Fair random numbers in any range, or a random pick from a list
Set the range and press Generate. Every whole number in the range has the same chance.
Random numbers
Press Generate.
How these were made
Not for anything that matters legally: do not use this page for lotteries, raffles, prize draws or any draw with money or legal consequences. Those need an approved, audited draw.
Pick from your own list
Press Pick.
How the randomness is made
Numbers come from your browser's cryptographic random source (crypto.getRandomValues), the same source used to make encryption keys. Nothing is sent to a server, and the page cannot be steered towards any number.
The browser hands over a random 53-bit number (a whole number from 0 to about 9 thousand million million). To turn it into a number in your range without favouring any of them, the page uses rejection sampling: if the random number falls in the small leftover slice above the last whole multiple of your range's size, it is thrown away and a new one is drawn. Simply taking the remainder would make the lowest numbers in some ranges slightly more likely; this method does not.
No repeats
With "No repeats" ticked, a number already picked is skipped and another is drawn, so every set of different numbers is equally likely. You cannot ask for more different numbers than the range holds: 1 to 10 has only 10.
Picking from a list
Each line of the list is one item, numbered from 1. The page picks item numbers in the same fair way. Blank lines are ignored. With "Each item at most once", the list is shuffled by the Fisher–Yates method and the first items are taken, which is the standard fair shuffle.
What it is good for, and what it is not
It suits games, classroom questions, choosing who goes first, sampling rows from a spreadsheet and picking a winner among friends. It is not for lotteries, raffles, prize draws or anything with legal or money consequences: those must use an approved, audited draw, and many places have laws about how they are run.
Formula and sources
- Random source: W3C Web Cryptography API, Crypto.getRandomValues() (a cryptographically strong random number generator).
- Unbiased range mapping by rejection sampling, and the Fisher–Yates shuffle: Knuth, The Art of Computer Programming, volume 2, sections 3.4.1 and 3.4.2.
- Checked in test_maths.js: 60,000 dice rolls land within normal chance of 10,000 on each face (chi-square test); a fake source shows a draw above the last whole multiple is rejected; no-repeat picks never repeat; asking for 11 different numbers from 1 to 10 is refused.