Random number guides: how generators work and where they fail

A random number looks like the simplest thing a computer can produce, and it is one of the easiest to get subtly wrong. The guides in this section explain where the numbers come from, what separates a generator you can rely on from one you cannot, and which tool to reach for when the outcome has to hold up — a classroom draw, a giveaway, a test dataset.

Where to start

Read what a random number generator is: hardware, pseudorandom and cryptographically secure generators, why numbers repeat, and what the browser has to offer. When you need numbers rather than an explanation, the random number generator draws them in your browser in any range, with or without repeats.

Where generators quietly go wrong

A strong source of randomness is only half the job. The other half is mapping its raw values onto your range, and that is where many homemade generators fail. Taking a value modulo the size of the range is the obvious approach, and it is subtly biased: unless the size of the range divides the source's output space evenly, the lowest numbers in the range come up slightly more often than the rest. The flaw is called modulo bias. One fix is rejection sampling: throw away the values that fall in the uneven tail and draw again. Our generator does this, so every number in your range has the same chance on every draw.

The same reasoning rules out the shortcuts people reach for first. Math.random() promises nothing about security, and spreadsheet functions such as RAND() and RANDBETWEEN() belong to the same class: fine for a rough shuffle, wrong for anything somebody might contest.

Numbers, lists and dice

A random number generator returns numbers from a range you set. A random picker works on a list you paste in — names, entries, options — so you never have to match numbers back to rows by hand. For tabletop games the dice roller rolls the dice and adds up the totals, and for a choice between two the coin flip is enough. When randomness has to protect something rather than decide something, use the strong password generator. All of them draw on the same cryptographically secure source in your browser.

Ready to use the tool?

Try our free and secure Random Number Generator tool directly in your browser.

Open Tool