/tools/random-number-generator

Random Number Generator

Pick numbers from a range using cryptographic randomness. Turn off duplicates for draws, raffles and lottery-style selections.

Random Number GeneratorRuns in your browser
Presets
—
press generate

How to use the Random Number Generator

  1. Set the minimum and maximum, and how many numbers you want.
  2. Switch on "No duplicates" for a draw, raffle or lottery selection.
  3. Press Generate. Results of more than twelve numbers also appear as a copyable list.

Where the randomness comes from

This tool uses crypto.getRandomValues, the browser's cryptographically secure generator, which draws from entropy collected by your operating system. That is a meaningful upgrade over Math.random, whose output is predictable if an attacker observes enough of it.

For a dice roll it makes no practical difference. For anything with a prize attached, or where someone might benefit from predicting the outcome, it matters.

Avoiding modulo bias

The obvious way to get a number from 1 to 6 is random % 6 + 1. It is subtly wrong. If the underlying generator produces values 0 to 9, then 0–5 map to each result once but 6–9 wrap around to give 1–4 a second chance. Those outcomes become more likely.

The fix is rejection sampling: discard any raw value that falls in the uneven tail and draw again. This tool does that, so every number in your range is equally likely. Most quick implementations skip it, which is why homemade random pickers often show a measurable skew over thousands of draws.

Unique selection done properly

Picking unique numbers by drawing repeatedly and discarding duplicates works badly when you want most of a range — selecting 45 unique numbers from 1 to 50 spends most of its time rejecting collisions.

Instead, this tool builds the full range and runs a partial Fisher–Yates shuffle, taking as many values as you asked for. Every possible combination is equally likely, and it runs in constant time per number regardless of how much of the range you want.

Frequently asked questions

Is this random enough for a prize draw?

The randomness is cryptographically sound and unbiased. Whether it satisfies a regulator is a separate question — formal draws often require an auditable, witnessed process rather than any particular algorithm.

Can I generate decimals?

Not currently — output is whole numbers. For two decimal places, generate in a range a hundred times larger and divide the result by 100.

Are the results the same for everyone?

No. Each visitor draws from their own device's entropy source. There is no shared seed and no server involved.

Can I get the same sequence again?

No. There is no seed to set, which is deliberate — a reproducible sequence would undermine the point of a secure generator. If you need reproducibility, use a seeded generator in code.

Related tools