Settings
Results
How This Random Number Generator Works
This tool generates whole numbers within a range you choose, using the browser's Web Crypto API (crypto.getRandomValues()) instead of the more commonly used Math.random(). The Crypto API draws from your operating system's cryptographically secure random source, which is both harder to predict and more suitable for fairness-sensitive uses like raffles, dice rolls, or drawing lottery numbers.
Why a naive random range calculation is biased
A common shortcut for turning a random number into a range is to take the remainder after dividing by the range size (random % range). That approach is subtly biased: unless the range divides evenly into the generator's total output space, some remainders come up slightly more often than others — an effect called modulo bias. It's small for a narrow range like 1-6, but grows for wider or awkward ranges.
How this tool avoids that bias
Instead of taking the remainder directly, this generator uses rejection sampling: it computes the largest multiple of your range size that fits inside the generator's output space, and simply throws away and re-draws any random value that falls in the small leftover portion above that multiple. What remains is mapped onto your range with the remainder operation, but now every value in the range has exactly equal probability, with no leftover bias.
How to use it, step by step
- Enter a Minimum and Maximum — negative numbers are allowed.
- Enter how many numbers you want (up to 1,000).
- Optionally list numbers to exclude, and tick "No duplicate numbers" or "Sort results" as needed.
- Click Generate. Copy the comma-separated list with the Copy button if you want to save it — nothing is stored automatically.
Unique numbers and range limits
When "No duplicate numbers" is ticked, the pool of possible values is your range minus any excluded numbers, and you can never draw more unique numbers than that pool contains. If you ask for more than the pool allows, the tool tells you instead of silently generating fewer numbers than requested.