About Random Number Generator: Guide & Practical Notes
Running a classroom draw, giveaway, or statistical sample with `Math.random()` multiplied by range length introduces slight modulo bias and lacks cryptographic unpredictability.
Generates 1 to 500 random integers within any inclusive `[Min, Max]` integer interval using `crypto.getRandomValues()` with unbiased rejection sampling, optional no-duplicates unique mode, and ascending sorting.
How to Use Random Number Generator Step by Step
- Enter Min Integer and Max Integer (inclusive bounds).
- Set Count (1 to 500) and toggle Unique numbers only or Sort ascending.
- Click Generate Numbers and copy the output.
Worked Example
Draw 5 unique winners from ticket numbers 1 through 100.
Inputs: Min = 1, Max = 100, Count = 5, Unique = ON, Sort = ON
Result: 5 distinct uniformly random integers sorted ascending (e.g., `7, 19, 44, 68, 92`).
Rejection sampling guarantees every integer from 1 to 100 has exact probability 1/100.
Eliminating Modulo Bias With Rejection Sampling
When dividing a 32-bit random unsigned integer (`0..2³²−1`) by a range like `100`, the remainder slightly favors smaller outputs unless values above the largest multiple of `100` are discarded and resampled—which `cryptoRandomInt()` enforces cleanly.
Common Real-World Uses
- Picking fair raffle, giveaway, or classroom student numbers
- Generating randomized dice rolls, lottery test sets, or sampling indices
- Creating non-repeating random draw orders
Common Mistakes to Avoid
- Forgetting to check "Unique numbers only" when drawing multiple raffle winners (allowing one ticket to win twice).
- Typing decimals in integer bounds.
Supported Formats, Scope & Limitations
When "Unique numbers only" is checked, Count cannot exceed `Max - Min + 1`.
Privacy & Local Processing
Random values draw locally from browser OS entropy.
Frequently Asked Questions
Are Min and Max numbers inclusive?
Yes. Setting Min = 1 and Max = 6 models a standard 6-sided die where both 1 and 6 can appear.
Why does this use Web Crypto instead of `Math.random()`?
Web Crypto `getRandomValues()` uses OS cryptographic entropy and prevents predictable PRNG states.
Need random alphanumeric tokens or hex keys instead of numbers? Open the Random String Generator.