Random Number Generator

Last updated: May 2026

Generate random integers or decimals within any range, produce a list of unique random numbers, roll dice, or flip a coin.

Warning: the range has fewer unique values than requested. Showing all available unique values.
Dice type

Random Numbers, Dice, and How Randomness Works

A random number generator (RNG) produces numbers with no predictable pattern. In computer science, true randomness is surprisingly hard to achieve — computers are deterministic machines that follow exact instructions. What most software uses instead is a pseudo-random number generator (PRNG), an algorithm that produces a long sequence of numbers that statistically behave like random outputs. Common algorithms include the Mersenne Twister (used in Python and many other languages) and xorshift. These algorithms start from a "seed" value and deterministically generate their sequence — given the same seed, you get the same sequence every time.

For most everyday uses — picking raffle winners, generating quiz questions, rolling dice in tabletop games, or creating test data — a PRNG is more than sufficient. Cryptographic applications (passwords, encryption keys) require a cryptographically secure PRNG (CSPRNG), which uses additional entropy sources like hardware timing, mouse movements, or OS-level random noise pools. Browser-based generators, including this one, use JavaScript's Math.random() or the Web Crypto API's crypto.getRandomValues() for stronger randomness. For dice rolls and casual picks, either approach is perfectly fair.

DieSidesCommon UseProbability of Any Result
d44Damage (daggers, magic missiles)25.00% (1 in 4)
d66Damage, Yahtzee, board games16.67% (1 in 6)
d88Damage (longsword, healing potions)12.50% (1 in 8)
d1010Damage, percentile rolls10.00% (1 in 10)
d1212Damage (greataxe), hour rolls8.33% (1 in 12)
d2020Attack rolls, saving throws (D&D)5.00% (1 in 20)
d100100Percentile skill checks, loot tables1.00% (1 in 100)

Worked Examples

Example 1 — Probability of rolling at least 15 on a d20
A d20 has 20 equally likely outcomes. The outcomes that satisfy "15 or higher" are: 15, 16, 17, 18, 19, 20 — that's 6 outcomes. Probability = 6 ÷ 20 = 30%. In D&D terms, if you need to hit a target number of 15, you have a 30% chance of success on any given roll.
Example 2 — Probability of rolling the same number twice in a row on a d6
The first roll can be anything (probability = 1). The second roll must match the first: probability = 1/6 ≈ 16.67%. So the combined probability of any matching pair on two consecutive d6 rolls is 1 × 1/6 = 16.67%. This is why the "house always wins" — streaks feel rare but happen at exactly the rate probability predicts.

Frequently Asked Questions

Is a computer-generated random number truly random?

Most computer random numbers are pseudo-random, not truly random. They are generated by a deterministic algorithm seeded with an initial value. The output is statistically indistinguishable from true randomness for most purposes, but it is technically reproducible if you know the seed and algorithm. Truly random numbers require a physical entropy source such as radioactive decay, thermal noise, or hardware timing jitter.

What is a PRNG?

PRNG stands for Pseudo-Random Number Generator. It is an algorithm that uses a starting value (the seed) to produce a long, complex sequence of numbers that passes statistical tests for randomness. The Mersenne Twister, used in Python's random module, has a period of 2^19937 − 1, meaning it won't repeat its sequence for an astronomically long time. For non-cryptographic applications, PRNGs are universally considered acceptable.

What is the difference between random and pseudo-random?

True randomness is unpredictable and non-reproducible — even with perfect knowledge of the system. Pseudo-randomness is deterministic: given the same seed, the same sequence is produced every time. In practice, the distinction matters primarily for cryptography and security. For games, simulations, sampling, and general tools, pseudo-random generators are considered equivalent to truly random.

How are dice probabilities calculated?

For a fair die with N sides, each face has an equal probability of 1/N. The probability of rolling a specific value is 1/N; the probability of rolling within a range is (number of values in range)/N. For multiple dice, multiply probabilities for independent events or sum probabilities for mutually exclusive outcomes. Rolling 2d6 and getting a 7, for example, has 6 favorable outcomes out of 36 total = 16.67% probability.

What does "seed" mean in random number generation?

A seed is the initial input value fed into a PRNG algorithm. Since the algorithm is deterministic, the same seed always produces the same sequence of "random" numbers. This is intentional and useful: game developers use fixed seeds to create reproducible procedural worlds (Minecraft's world seeds work this way), and scientists seed their simulations so experiments can be replicated exactly. When you want different results each time, the seed is typically set to the current timestamp or OS entropy.