Credibrate

Random Number Generator

Generate random numbers in any range. Set a minimum, maximum, and how many numbers you want. Toggle off duplicates to get a unique set — useful for lottery picks, random sampling, and games.

How Random Number Generator works

True random vs pseudorandom

Standard programming languages use pseudorandom number generators (PRNGs) — deterministic algorithms that produce sequences that appear random but are derived from a seed. Math.random() in JavaScript is a PRNG. For applications requiring higher quality randomness — lottery picks, cryptographic tokens, security keys — the Web Cryptography API provides crypto.getRandomValues(), which draws from the operating system's entropy pool. This calculator uses crypto.getRandomValues().

Unique numbers without repeats (Fisher-Yates shuffle)

To generate N unique numbers from a range, the generator creates the full array of possible values, shuffles it randomly using the Fisher-Yates algorithm, then takes the first N elements. Fisher-Yates guarantees that every permutation is equally probable and no value is repeated. Each swap in the shuffle uses a fresh cryptographically random value.

Modulo bias

When using a random integer from a range that does not evenly divide into the random source range (2^32 for 32-bit outputs), small values are slightly more likely than large ones. For ranges up to a few million, this bias is negligible in practice (less than 0.00001%). For cryptographic applications requiring perfect uniformity, rejection sampling eliminates the bias. For everyday uses like lottery picks and games, modulo sampling is entirely adequate.

Common uses

Random number generators are used for lottery and raffle draws, random sampling in surveys and audits, randomising teams or seating arrangements, tabletop games and board games, generating test data, and any context where an unbiased choice between options is needed. For truly fair draws, the cryptographic quality of this generator exceeds what is needed in practice.

Frequently asked questions

Is this random number generator truly random?

It uses crypto.getRandomValues(), which draws from the operating system's entropy pool rather than a deterministic algorithm. This produces cryptographic-quality randomness, which is significantly better than Math.random() and suitable for security-sensitive applications. It is as close to truly random as practical software can get.

Can I generate lottery numbers with this?

Yes — set minimum to 1, maximum to 59 (for the UK National Lottery main draw), count to 6, and turn duplicates off. The generator will produce 6 unique numbers in the range 1–59, which you can then sort. The randomness quality is appropriate for this purpose.

What is the maximum range I can use?

The calculator supports any integer range. For unique number generation without duplicates, the range size (max − min + 1) must be at least as large as the count requested. For ranges with millions of values, the unique mode creates the full array in memory, which may take a moment for very large ranges.

Why is the number different each time I click Generate?

Each click triggers a fresh call to the random number generator. No state is shared between generations. Even with the same settings, each click produces an independent, unpredictable result.

Related calculators