Random Number Generator
Generate secure random numbers in any range: whole numbers or decimals, up to 1,000 at once, with or without repeats, sorted or not.
- Free
- No sign-up
- Runs in your browser
Random Number
Runs in your browser. Your inputs never leave your device.
In short
Quick Answer
Enter a minimum, a maximum and how many numbers you need, then press Generate. Each number is drawn with crypto.getRandomValues, the browser's cryptographically secure generator, and rejection sampling so every value in the range is exactly equally likely. Turn off duplicates for a draw where no number repeats, such as a raffle.
Step by step
How to Use
- Set the range. Enter the smallest and largest number allowed.
- Choose how many. Enter how many numbers you need, up to 1,000.
- Pick the options. Allow or forbid duplicates, sort the results, and choose whole numbers or up to 6 decimal places.
- Generate and save. Press Generate, then copy the numbers or download them as a text file.
Why Secure Randomness and Rejection Sampling Matter
Computers cannot flip coins, so they use algorithms. Ordinary generators such as JavaScript's Math.random() produce numbers that look random but follow a hidden pattern. Cryptographically secure generators, exposed in browsers as crypto.getRandomValues, are seeded from unpredictable events gathered by the operating system and are designed so that seeing earlier outputs does not help predict the next one.
Getting a number in a range also needs care. A secure generator returns values from 0 to 4,294,967,295. To get a number from 1 to 6 you might take the remainder after dividing by 6, but 4,294,967,296 is not a multiple of 6, so the remainders 0 to 3 would come up very slightly more often than 4 and 5. This tool throws away the handful of raw values that cause that imbalance and draws again, so every face is exactly equally likely.
| Use | Range | Chance of each value |
|---|---|---|
| Coin toss | 1–2 | 1 in 2 (50%) |
| Six-sided die | 1–6 | 1 in 6 (16.67%) |
| Percentage roll | 1–100 | 1 in 100 (1%) |
| Day of the year | 1–365 | 1 in 365 (0.27%) |
| Four-digit PIN | 0–9999 | 1 in 10,000 (0.01%) |
Ideas for Using Random Numbers
- Prize draws: number the entries and draw winners without duplicates.
- Teaching and research: pick random students, survey participants or sample rows from a spreadsheet.
- Games: replace lost dice, choose who goes first, or set up random scenarios. The coin flip and dice roller shows dice faces and keeps a history.
- Testing: generate test data with decimals or very large ranges, then download it as a file.
Everything runs in your browser. The numbers are generated on your device and never sent to a server.
The math
How the Numbers Are Drawn
n = max − min + 1 · draw x uniformly from [0, 2³²) · reject x ≥ 2³² − (2³² mod n) · result = min + (x mod n)
The browser's secure random source gives 32-bit numbers. Taking x mod n directly would make small results slightly more likely whenever n does not divide 2³² evenly (modulo bias), so draws in the uneven top slice are thrown away and redrawn. Every value then has probability exactly 1 ÷ n. Decimals with N places are drawn the same way as whole numbers of 10^−N steps between the minimum and maximum. Without duplicates, each value is drawn at most once (sampling without replacement).
- n: How many different values are possible: max − min + 1 for whole numbers.
- Rejection sampling: Discarding the few raw draws that would bias the result; on average less than one extra draw is needed.
- Without duplicates: You can draw at most n numbers, because after that every value has been used.
Examples
Worked Examples
Roll a six-sided die
Min 1, max 6, how many 1
- n = 6 possible values
- 2³² mod 6 = 4, so the top 4 raw values out of 4,294,967,296 are rejected
Result: One number from 1 to 6, each with probability 1/6
Lottery-style draw: 6 numbers from 1 to 49
Min 1, max 49, how many 6 · Allow duplicates: off, sort: on
- Each number is drawn from those not yet picked
- There are 13,983,816 possible sets of 6
Result: Six different numbers in ascending order
Random decimals between 0 and 1
Min 0, max 1, how many 5 · Decimal places: 3
- Values are steps of 0.001, so n = 1,001 possible values
- Each draw is a whole number of steps, divided by 1,000
Result: Five numbers such as 0.417, each from 0.000 to 1.000
Watch out
Common Mistakes to Avoid
- Using Math.random() for anything that matters: Math.random() is fast but not designed to be unpredictable, and its output can sometimes be reconstructed. For prize draws, passwords or anything security-related, use a cryptographic source such as crypto.getRandomValues, as this tool does.
- Using x mod n on a raw random number: Reducing a random number with % n without rejection sampling gives a small bias towards lower values when n does not divide the generator's range evenly. The effect is tiny for small n but real, and easy to avoid.
- Asking for more unique numbers than the range holds: There are only 10 different whole numbers from 1 to 10, so you cannot draw 11 without a repeat. The tool tells you when the count is larger than the range.
- Expecting random numbers to look evenly spread: Real randomness produces streaks and clusters. Rolling three 6s in a row on a fair die happens about once in 216 tries; it is not evidence that the generator is broken.
- Treating decimals as continuous: With 2 decimal places between 0 and 1 there are exactly 101 possible values. If you need finer values, increase the decimal places.
FAQ
Frequently Asked Questions
Is this random number generator truly random?
It uses crypto.getRandomValues, a cryptographically secure generator built into your browser and seeded by your operating system's entropy sources. It is suitable for games, draws and sampling, and the numbers cannot be predicted from earlier ones.
How do I generate a random number between 1 and 100?
Set the minimum to 1, the maximum to 100 and how many to 1, then press Generate. Each number from 1 to 100 has exactly a 1% chance.
How do I pick random numbers without repeats?
Untick Allow duplicates. Every number in the result will be different, as long as you do not ask for more numbers than the range contains.
Can I generate random decimal numbers?
Yes. Choose 1 to 6 decimal places. The numbers are spread evenly across the range in steps of that size.
How many random numbers can I generate at once?
Up to 1,000 per click. Copy them or download them as a text file, one number per line.
Can I use this for a raffle or giveaway?
Yes. Number the entries, set the range to match, untick duplicates and draw as many winners as you need. For names instead of numbers, use the random name picker.
Are my numbers sent anywhere?
No. The numbers are generated in your browser and are not sent to or stored on a server.
References