What is a Random Number Generator?
A random number generator (RNG) is a tool that produces numbers or selections that have no predictable pattern. Our generator uses JavaScript's built-in Math.random() function to create pseudo-random results suitable for everyday use cases.
This tool offers two modes: Random Numbers for generating numbers within a range, and Random Picker for selecting items from a custom list.
Random Number Mode
Generate one or more random integers between a minimum and maximum value. Perfect for dice rolls, lottery numbers, random sampling, or any situation where you need random numbers.
Random Picker Mode
Enter a list of items separated by commas, and the generator will randomly select one or more items. Great for making decisions, choosing winners, or randomizing selections.
Common Use Cases
- Games & Gaming: Dice rolls, card draws, random encounters
- Raffles & Giveaways: Select random winners from a list of participants
- Decision Making: Can't decide? Let randomness choose for you
- Education: Generate random quiz questions or student order
- Statistics: Create random samples for surveys or research
- Team Selection: Randomly assign people to groups or teams
Duplicates Option
The "Allow Duplicates" checkbox controls whether the same number or item can appear multiple times in your results. When disabled, each result will be unique - useful for lottery-style selections or when you need distinct items.
How computers generate randomness
The Math.random() call behind this tool is not random in the physical sense. It is a pseudo-random number generator (PRNG): an algorithm that starts from a hidden seed and applies the same arithmetic step over and over, producing a stream that looks patternless but is fully determined by that seed. In V8, the engine that powers Chrome and Node.js, the algorithm is xorshift128+. Feed it the same seed and it returns the same sequence every time, which is exactly why you should not use it to generate passwords, tokens, or anything an attacker might want to predict. For those cases browsers expose crypto.getRandomValues(), a cryptographically secure generator seeded from operating-system entropy.
| Type | Example | Predictable? | Use it for |
|---|---|---|---|
| PRNG | Math.random() | Yes, from the seed | Games, raffles, sampling |
| CSPRNG | crypto.getRandomValues() | No, practically | Keys, tokens, passwords |
| True / hardware RNG | Thermal noise, radioactive decay | No | Lottery draws, key seeding |
The formula this tool uses
Math.random() returns a float in the half-open interval [0, 1). To map it onto whole numbers from min to max the standard expression is Math.floor(Math.random() * (max - min + 1)) + min. The +1 is where most people slip up. Drop it and you can never roll the maximum value, so a d6 written as Math.floor(Math.random() * 6) yields 0 through 5 instead of 1 through 6. A second trap is modulo bias: taking a large random integer and reducing it with % 6 splits the range unevenly when 6 does not divide it cleanly, quietly favouring the lower faces. Multiplying the float directly, as above, keeps every outcome equally likely.
Worked example: your odds of a 6-from-49 jackpot
Set the range to 1-49, the count to 6, and turn duplicates off. Order does not matter on a ticket, so the number of possible tickets is the combination C(49, 6) = (49 x 48 x 47 x 46 x 45 x 44) / (6 x 5 x 4 x 3 x 2 x 1). The numerator works out to 10,068,347,520 and the denominator to 720, giving 13,983,816 distinct tickets. Your chance of matching the drawn set is therefore exactly 1 in 13,983,816. Generating a fresh set does nothing to improve those odds; every one of those combinations is equally likely, including 1-2-3-4-5-6.
Worked example: how often a repeat sneaks in
Now leave duplicates on and draw 10 numbers from 1-100. It feels like repeats should be rare across only 10 picks, but this is the birthday paradox in disguise. The probability of no repeat is the product of the shrinking odds each draw stays fresh: 1 - 100! / (100^10 x 90!) = 1 - (100 x 99 x 98 x ... x 91) / 100^10, which is about 1 - 0.628 = 0.372. So there is roughly a 37% chance that at least two of your 10 numbers match. Humans consistently underestimate this, which is part of why we are poor judges of what a random sequence should look like.
Common presets and the settings to enter
| Preset | Range | Count | Duplicates |
|---|---|---|---|
| Coin flip | 0 - 1 | 1 | n/a |
| Single die (d6) | 1 - 6 | 1 | n/a |
| Two dice (2d6) | 1 - 6 | 2 | on |
| Polyhedral (d20) | 1 - 20 | 1 | n/a |
| Powerball (main) | 1 - 69 | 5 | off |
| Powerball (red) | 1 - 26 | 1 | n/a |
| EuroMillions (main) | 1 - 50 | 5 | off |
| EuroMillions (stars) | 1 - 12 | 2 | off |
Randomness misconceptions
The gambler's fallacy is the belief that a number is "due" after a dry spell. Each generation here is independent, so a value that has not appeared in nine draws is no more likely on the tenth. By the same logic 1-2-3-4-5-6 wins any lottery with the identical probability as a scattered-looking ticket; it only feels less random because our brains treat orderly patterns as unnatural. Genuinely random streams contain clusters and short runs, and expecting them to be perfectly spread out is itself the mistake.