RANDOMNESS / 5 MINUTE READ

How can a browser choose something randomly?

Computers follow instructions precisely, which makes the idea of a random computer result sound contradictory. Modern browsers solve the problem by gathering unpredictable information from the device and operating system.

Pseudorandom and cryptographic randomness

A basic pseudorandom number generator begins with a seed and applies a repeatable mathematical process. It can be perfectly suitable for animation or simulation, but the sequence can be reproduced if the seed and algorithm are known.

A cryptographically secure random-number generator is designed to make future values impractical to predict. Browsers expose this capability through the Web Crypto API. It draws on entropy collected by the operating system rather than relying only on a simple formula inside the page.

Turning random bits into a range

The browser initially returns a large unsigned integer. To choose a number from 1 to 100, the tool maps that large space into one hundred equally likely buckets. Care is required: a naïve remainder operation can make some values microscopically more likely when the source range is not evenly divisible by the target range.

Rejection sampling avoids that modulo bias. Values in the small uneven remainder are discarded and sampled again. The resulting buckets have equal sizes.

Equal odds in different tools

What randomness cannot guarantee

Fair randomness does not promise balanced short-term results. A D6 can roll six three times in a row. A name can be selected twice if winners are not removed. Those outcomes may feel suspicious, but unusual sequences are part of randomness rather than proof against it.

Try a cryptographically generated range.

Open the Random Number Generator →

Use the right tool for the stakes

Browser randomness is excellent for games, classroom activities, creative prompts, and casual drawings. Formal lotteries, regulated gaming, security keys, and high-value promotions can require audited systems, recorded procedures, or jurisdiction-specific rules. A convenient public tool is not a replacement for those controls.