Math · Live
Random numbers,
truly unpredictable.
A free random number generator backed by your browser's cryptographic entropy. Pick a range, set how many integers or decimals you want, and roll, with optional no-duplicates and ascending sort. Suitable for raffles, lottery picks, dice rolls, or statistical sampling.
Inputs
Range & rules
- Range size
- 100
- Picks
- 1 of 100
- Source
- crypto.getRandomValues
Random number
1 – 100
INT
Field guide
How a random number generator should work.
“Random” in computing means two things at once: the statistical property of being unbiased — every outcome in the range has the same chance and the cryptographic property of being unpredictable, even to someone who knows the previous outputs. Most casual generators get the first part right and quietly fail the second. This generator gets both.
Why Math.random isn't enough
JavaScript's Math.random() returns a uniformly distributed number in [0, 1), which is fine for a shuffled playlist but explicitly not safe for anything adversarial. Every major browser uses a pseudo-random generator (xorshift+ or similar) seeded once at page load. An attacker who observes a few outputs can often reverse the seed and predict every future call. So we don't use it.
The Web Crypto API
Instead, this calculator calls crypto.getRandomValues(), which is wired directly to the operating system's cryptographic random source — /dev/urandom on Linux/macOS,BCryptGenRandom on Windows. The output is indistinguishable from true randomness for any practical attacker.
crypto.getRandomValues(buf)
Avoiding modulo bias
A naive integer generator does min + rand32 % range. That's biased whenever range doesn't divide 2³² evenly — small numbers in the leftover cell are slightly more likely than large ones. For a die rolling 1–6 the bias is negligible; for ranges above ~10⁹ the skew is measurable. This generator uses rejection sampling: discarding any draw that lands in the leftover region, so every value in the range has exactly the same probability.
Decimals, properly
For floating-point output, we combine two 32-bit draws into a 53-bit mantissa (the full precision of IEEE-754 doubles) and scale into the requested range. The result is then rounded to the requested number of decimal places — no precision is invented that the encoding can't represent.
Uniqueness without bias
When “No duplicates” is on, the generator builds the full range as an array and applies a partial Fisher-Yates shuffle, taking the first N entries. That gives an unbiased uniform sample without the rejection-loop slowdown that naive set-based approaches hit when count approaches the range size. For very large ranges (over ~50,000 integers), it falls back to a Set-based draw.
Common uses
- Raffles & giveaways: generate a unique winner index from your entry list.
- Lottery picks: five or six unique numbers from a fixed pool (e.g. 1–69 for Powerball whites).
- Dice rolls: one or several integers in 1–6, 1–20, etc.
- Statistical sampling: selecting random row indices from a dataset.
- Tabletop games: random encounters, treasure rolls, deck shuffles.
What this calculator doesn't do
We don't generate random strings or passwords here — for cryptographic passwords use a dedicated tool that mixes character classes and enforces minimum entropy. We also don't persist results: each generation is fresh and nothing is saved server-side.
Worked examples
Pick a Powerball white-ball set: set Min to 1, Max to 69, How many to 5, and turn on No duplicates and Sort ascending. You'll get five unique numbers in order. (Run a second generation with Min 1, Max 26, How many 1 for the red Powerball.)
Roll 4 D6: Min 1, Max 6, How many 4, duplicates allowed.
Sample 10 rows from a 5,000-row dataset: Min 0, Max 4999, How many 10, no duplicates.
Disclaimer
All output is generated client-side in your browser and never transmitted anywhere. For high-stakes use (regulated gambling, certified random draws), use a vendor with published auditability, but this generator's underlying entropy source is the same one those systems rely on.