Random Number Generator

Generate random numbers in any range with cryptographically secure randomness. Choose how many numbers, allow or block duplicates, and sort the results.

Random Numbers
—
Set a range and press Generate

Quick Examples

What Is a Random Number Generator?

A random number generator (RNG) selects numbers from a defined range with no predictable pattern. Every number in the range has exactly the same chance of being picked on every draw, and each draw is independent of the ones before it — like drawing a numbered ball from a bag without looking, then putting it back.

Randomizers are everywhere: raffles and giveaways, lottery draws, dice and board games, shuffling playlists, assigning experiment groups, and sampling data for statistics. This page explains how the generator above works, what makes its output trustworthy, and how to use it for dice, coins, lotteries, and draws.

How This Generator Works

Enter a minimum and maximum (both inclusive), choose how many numbers to generate (up to 1,000 at a time), and optionally tick no duplicates or choose a sort order. The numbers are drawn with the Web Crypto API's crypto.getRandomValues(), which pulls from your operating system's cryptographically secure entropy pool rather than a simple arithmetic pseudo-random sequence.

Rejection sampling against modulo bias: naively taking a random 32-bit integer modulo the range size makes some outcomes slightly more likely, because 2³² = 4,294,967,296 is rarely an exact multiple of the range — for a range of 100 it leaves a remainder of 96. This generator discards values in that uneven remainder region before applying the modulo, restoring an exactly uniform distribution.

True Randomness vs. Pseudo-Randomness

Not all "random" is equal. Three tiers of random sources are worth knowing:

SourceHow It WorksTrust LevelTypical Use
Math.random()Pseudo-random, seeded by the browser engineNot for anything where prediction mattersGames, animations, shuffling a playlist
crypto.getRandomValues() (used here)Cryptographically secure, seeded from OS entropySuitable for draws, raffles, tokensAnything fair or security-sensitive
Hardware generatorSamples physical noise (thermal, atmospheric) directlyHighest assuranceCryptographic key generation, gambling machines

A pseudo-random generator like Math.random() is deterministic: knowing the seed reproduces the whole sequence — useful for simulations, unacceptable for security. Cryptographically secure generators are designed so that past output reveals nothing about future output.

Uniform Distribution and Independent Draws

Every value in the range is equally likely: with a range of 1 to 10, each number has a 1-in-10 chance (10%) on every draw. Getting a 7 once does not make 7 more or less likely next time — each draw is independent — the defining property of a fair draw, and the one people most often misunderstand.

Common Ranges and the Chance of Any One Value

UseRangeChance of a Given Value
Coin flip0 to 150%
Six-sided die1 to 616.67%
Twenty-sided die1 to 205%
Percentile1 to 1001%
Lottery ball, 1 of 491 to 492.04%
Raffle with 500 tickets1 to 5000.2%

With vs. Without Duplicates

With repeats allowed, each draw is independent — the same number can appear more than once, exactly like rolling a die repeatedly. Use this for simulating independent trials.

With no duplicates, each drawn number is set aside and cannot be drawn again — like keeping the ball out of the bag. The result is a random sample without replacement, which is what raffles, lottery draws, and team drafts need. This mode requires the range to contain at least as many values as the count you request.

Simulating Dice and Coins Correctly

A coin is a range of 0 to 1; a six-sided die is 1 to 6; a twenty-sided die is 1 to 20. But two dice are not uniform: one die gives every face the same chance, while the sum of two dice does not, because there are more ways to make a 7 than a 2.

TotalWays (of 36)Probability
212.78%
325.56%
438.33%
5411.11%
6513.89%
7616.67%
8513.89%
9411.11%
1038.33%
1125.56%
1212.78%

To simulate two dice, generate two numbers from 1 to 6 and add them — never a single number from 2 to 12, which would wrongly give every total the same 1-in-11 chance.

Lottery Numbers and Odds

For a lottery-style draw, set the range to the ball pool, the count to the number of picks, enable no duplicates, and sort ascending — the "Lottery 6 of 49" quick example does exactly this. Choosing 6 numbers from 1 to 49 can be done 13,983,816 ways, so one ticket's jackpot chance is 1 in 13,983,816. Random picks cannot predict draws or improve the odds, but they do guarantee a ticket free of human pattern bias.

Real-World Uses

  • Raffles and giveaways: pick winners fairly from numbered entries with no duplicates.
  • Games: roll dice, flip coins, or seed procedural content.
  • Statistical sampling: draw unbiased random samples from a numbered population.
  • Experiment design: randomly assign participants to A/B test groups.
  • Classroom demos: illustrate probability and sampling variation live.

A note on passwords: the randomness quality here is fine, but passwords need letters, symbols, and guaranteed character-class coverage, which a number generator cannot provide. Use a dedicated password generator for credentials.

A Brief History of Random Number Generation

Humanity has randomized outcomes for millennia. Archaeologists have unearthed early dice crafted from sticks, shells, and bones; the oldest known six-sided cubic dice trace back to the Indus Valley around 2500 B.C.

The digital age began in 1947, when the RAND Corporation built an electronic generator linking a roulette mechanism to a computer. In 1949, John von Neumann proposed the middle-square method, but its sequences inevitably collapsed into short repeating cycles. In 1956, ERNIE began drawing Britain's Premium Bond lottery numbers, and in 2012 Intel's RDRAND/RDSEED instructions brought hardware-grade randomness to mainstream processors.

Common Mistakes

  • The gambler's fallacy. After five coin-flip heads in a row, tails is still exactly 50%. Randomness has no memory.
  • Using Math.random() for security. It is deterministic and predictable — fine for games, never for tokens or secrets.
  • Hand-rolled modulo without rejection sampling. Taking a random integer modulo the range size biases results toward lower values whenever the range does not divide the integer space evenly.
  • Simulating two dice with one 2–12 draw. Real dice totals follow a triangular distribution peaking at 7, not a flat one.
  • Expecting small samples to look "even". True randomness clusters: a run of 4 heads in 20 flips is normal, not evidence of bias. Evenness emerges only over large samples.

Frequently Asked Questions

How do I generate a random number between two values?
Enter the minimum and maximum (both inclusive), set the count to 1, and click Generate. A range of 1 to 6 can produce any of 1–6, each with equal probability.
Are online random number generators truly random?
This generator uses crypto.getRandomValues(), drawing from your operating system's entropy pool — cryptographically secure, so past output reveals nothing about future output. Only hardware devices sampling physical noise rank higher.
What is the difference between Math.random() and crypto.getRandomValues()?
Math.random() is a fast, deterministic pseudo-random generator seeded by the browser — fine for games, never for anything where prediction matters. crypto.getRandomValues() is cryptographically secure and suitable for draws and raffles. This page uses the latter.
How do I generate random numbers without duplicates?
Tick the no-duplicates option: each drawn number is set aside, giving a random sample without replacement — like drawing raffle tickets from a hat. The range must hold at least as many values as your count.
How do I simulate a dice roll or a coin flip?
A coin is 0 to 1, a six-sided die is 1 to 6, a twenty-sided die is 1 to 20. For two dice, generate two numbers from 1 to 6 and add them — one draw from 2 to 12 would wrongly flatten the probabilities.
Can I use this generator for a raffle or giveaway?
Yes. The cryptographic source, uniform distribution, and rejection sampling against modulo bias make it suitable for fair draws. Cover your entry numbers with the range and enable no-duplicates for multiple winners.
Why should two dice be simulated with two separate draws?
Dice sums are not uniform: 7 has 6 ways out of 36 (16.67%) while 2 and 12 have 1 way each (2.78%). One draw from 2 to 12 gives every total a 1-in-11 chance, misrepresenting real dice.
Is it safe to use a random number generator for passwords?
The randomness quality is fine, but passwords need letters, symbols, and guaranteed character coverage, which numbers alone cannot provide. Use a dedicated password generator for credentials.

Conclusion

A good random number generator draws from a cryptographically secure source, gives every value an exactly equal chance (no modulo bias), and offers the controls real tasks need: count, uniqueness, and sorting. The traps are statistical, not technical — independent draws have no memory, and combined outcomes like two dice are not flat.

Use the random number generator above for raffles, dice, lotteries, and sampling — with crypto-grade randomness generated in your browser.