Random Number Generator
Draw numbers from a range, with or without repeats.
With and without replacement are different questions
Drawing with replacement means each number is picked independently from the full range, so duplicates can and will appear — this is the right model for simulating dice, generating independent samples, or anything where past draws should not constrain future ones. Drawing without replacement removes each number once picked, which is what you want for a lottery, a raffle, or selecting five distinct winners from a numbered list.
Choosing the wrong one is the most common mistake here. If you draw six winning tickets with replacement, you may well draw the same ticket twice.
Why modulo bias matters
The naive way to squeeze a random 32-bit value into a range is to take the remainder after division. This introduces a subtle bias: unless the range divides evenly into 2³², some outputs are produced by one more input value than others and appear slightly more often. For a small range the effect is tiny; for a large range relative to the source it becomes measurable, and for anything where fairness is contested it is worth avoiding entirely.
This generator uses rejection sampling instead — values falling in the biased tail are discarded and redrawn — so every number in your range is exactly equally likely.
Cryptographic randomness versus Math.random
JavaScript's Math.random() is a pseudorandom generator seeded once and advanced deterministically. It is fast, statistically decent for games and animation, and explicitly not suitable for anything security-sensitive: its output is not guaranteed unpredictable, and implementations have historically been weak. The Web Crypto API's getRandomValues draws from the operating system's entropy pool, which is what this tool uses. For a raffle nobody is attacking, either is fine; for anything where someone has an incentive to predict the result, the difference matters.
How to use it
- Set the minimum and maximum of your range, inclusive.
- Choose how many numbers to draw.
- Turn off repeats for raffles and winner selection; leave them on for simulation.
- For a contested draw, generate in front of the group rather than reporting the result afterwards.
Before you draw
Should I allow repeats?
Allow them when each draw should be independent, such as simulating dice. Disable them when you are selecting distinct items — a raffle drawn with repeats can pick the same ticket twice.
What is modulo bias?
Squeezing a random value into a range using the remainder operator makes some outputs slightly more likely than others when the range does not divide evenly. This tool uses rejection sampling to eliminate it entirely.
Is this random enough for a prize draw?
For fairness, yes — it draws from the operating system entropy pool via the Web Crypto API. For a legally regulated draw, follow whatever audit and witnessing requirements apply in your jurisdiction.
Are the numbers inclusive of the range ends?
Yes. Both the minimum and maximum you enter can be drawn, so a range of 1 to 10 can produce both 1 and 10.
Disclaimer: These tools are for games, classrooms, and informal group decisions. They are not audited for regulated lotteries, gambling, or any draw with legal requirements, and should not be used to make financial, medical, legal, or safety decisions.