Skip to main content

Online Calculator Lab

Random Number Generator

Generate random numbers, roll dice, flip a coin, or shuffle a list — pick your mode and generate instantly. 100% free.

Minimum
Maximum

What Is a Random Number Generator?

A random number generator (RNG) produces numbers that have no predictable pattern — each result is statistically independent of every previous one. This tool generates random integers or decimals in any range you set, rolls dice of any size, flips coins, or shuffles a list into a random order. All five modes use window.crypto.getRandomValues() — the browser's cryptographically secure random source — rather than the weaker Math.random() function.

Random numbers have practical uses far beyond games: statistical sampling, security key generation, randomized controlled trials, giveaway winner selection, seating assignments, blind taste tests, and classroom name picking. The core requirement in all these cases is the same — each outcome must have an equal probability with no influence from what came before.

How to Use This Tool

  1. 🔢 Numbers — set a min and max, choose integer or decimal, click Generate. Good for 1–10, 1–100, or any custom range.
  2. 📋 Multiple — generate a batch of numbers at once. Toggle "No duplicates" to avoid repeats (lottery-style picks). Toggle "Sort" to order results low to high.
  3. 🎲 Dice — roll 1–20 dice of any standard type: D4, D6, D8, D10, D12, D20, or D100. Shows each die face individually plus the total.
  4. 🪙 Coin — flip 1–100 coins at once. Shows heads/tails for each flip and a summary count.
  5. 🔀 List Shuffle — paste any list (one per line or comma-separated), get it back in a random order. Or toggle "Pick one" to select a single random item.
📌 Keyboard shortcut: Press Enter anywhere in the number fields to generate instantly — no need to click the button every time.

How RNG Actually Works

There are two fundamentally different types of random number generators. Understanding which type you're using matters for anything security-related.

PRNG (Pseudo-Random Number Generator): Uses a mathematical algorithm seeded from a starting value. Output looks random but is deterministic — same seed = same sequence. Example: Math.random() in most browsers uses XorShift128+ Period: ~2^128 before the sequence repeats Use case: games, simulations, statistics — fine for non-security use CSPRNG (Cryptographically Secure PRNG): Uses hardware entropy (CPU timing, mouse movement, thermal noise) Output is genuinely unpredictable — no seed knowledge can predict next value Example: window.crypto.getRandomValues() — used by THIS tool Use case: passwords, tokens, keys, anything requiring true unpredictability How this tool generates integers in range [min, max]: 1. Generate a 32-bit random integer via crypto.getRandomValues() 2. Map to range: result = min + (randomInt % (max - min + 1)) 3. Reject and retry if result falls in bias zone (rejection sampling) → Guarantees perfectly uniform distribution across the range
📌 Why rejection sampling? If the range doesn't divide evenly into 2³², simple modulo introduces a tiny bias toward lower numbers. Rejection sampling discards values in the bias zone and draws again — this tool applies it automatically, so all outputs are uniformly distributed.

Probability and What to Expect From a Random Range

Each number in a range has exactly equal probability. Here's what that means in practice across common ranges:

RangeTotal OutcomesP(any specific number)Common Use
0–1 (coin flip)250.0000%Decisions, binary choices
1–6 (die roll)616.6667%Board games, tabletop RPG
1–101010.0000%Rating scales, quick picks
1–52 (card deck)521.9231%Card game simulation
1–1001001.0000%Percentile picks, raffle
1–1,0001,0000.1000%Large draws, sampling

One counterintuitive result from probability: even with a perfectly fair generator, you'll see "streaks" — the same number appearing multiple times in a row. Getting the same number three times in a row when rolling a D6 feels suspicious, but the probability is (1/6)³ = 0.46% per set of three rolls — unlikely, but expected to happen roughly once in every 216 three-roll sequences. Streaks are a feature of true randomness, not a sign of a broken generator. Reference: Random.org — Introduction to Randomness

Dice Roll Probabilities

Rolling a single die gives equal probability for each face. Two dice together create a distribution skewed toward the middle — there are 6 ways to roll a 7 but only 1 way to roll a 2 or 12. Every value in the table below is computed from first principles (counting combinations out of 36 total two-dice outcomes):

Sum (2d6)CombinationsProbabilityRough Odds
2 or 121/362.78%1 in 36
3 or 112/365.56%1 in 18
4 or 103/368.33%1 in 12
5 or 94/3611.11%1 in 9
6 or 85/3613.89%5 in 36
7 (most likely)6/3616.67%1 in 6

A sum of 7 is six times more likely than rolling a 2 or 12 with two standard dice. This is why 7 is so central to games like Craps — it's the most probable single outcome from a 2d6 roll. Reference: Khan Academy — Basic Probability

Common Real-World Uses for Random Number Generators

Random number generation is one of the most widely applied tools in both everyday decisions and professional work. A few categories where it shows up:

  • Giveaways and winner selection — assign numbers to entries, generate a random number in that range. Transparent and auditable.
  • Research sampling — picking a random subset from a larger population for surveys, quality control audits, or clinical trials ensures the sample isn't unconsciously biased by the researcher's choices.
  • Games and simulations — dice rolls, card shuffles, enemy spawn locations, procedural map generation — all rely on RNG for variety and replayability.
  • Password and token generation — cryptographically secure random numbers are the foundation of secure passwords, session tokens, and one-time codes. This is specifically where PRNG (Math.random) fails and CSPRNG (crypto.getRandomValues) matters.
  • Decision-making — when two options are genuinely equal, a coin flip or random number eliminates deliberation paralysis. Studies show that people are happier with randomly-made decisions for low-stakes choices than with overthought ones.

Lottery Odds — Random Picks vs Strategies

Lottery jackpot odds are combinatorial — not affected by which specific numbers you choose, since all combinations are equally likely. Here's what the math actually says:

LotteryFormatJackpot OddsP(winning)
Powerball (US)5 from 69 + 1 from 261 in 292,201,3380.000000342%
Mega Millions (US)5 from 70 + 1 from 251 in 302,575,3500.000000331%
6 from 496 from 491 in 13,983,8160.00000715%
Pick 33 digits 000–9991 in 1,0000.10%

No number-picking strategy changes these odds — every combination of 5 numbers from 1–69 has exactly a 1 in 11,238,513 chance of being drawn, whether you pick birthdays, "lucky" numbers, or let a random generator choose. What the generator does is save you from unconsciously favoring numbers below 31 (common birthday bias) and ensures you don't share your combination with thousands of other players who pick the same "lucky" numbers. Reference: National Council on Problem Gambling — Lottery Odds

5 Smart Ways to Use This Random Number Generator

  • Raffle draws: assign numbers first, then generate. Give each entry a unique number (1, 2, 3…), then generate a random number in that range. Screenshot the result before revealing it. This is more defensible than picking a name from a hat because the process is auditable — anyone can verify the range and result.
  • Use Multiple mode with "no duplicates" for lottery picks. Generate 6 unique numbers from 1–49 for a lottery-style pick. The "no duplicates" checkbox uses rejection sampling internally — numbers already drawn are excluded from the pool, exactly replicating how physical lottery balls work.
  • List shuffle for fair rotation of tasks or turns. Paste team member names and shuffle — whoever appears first takes the first turn, first slot on the schedule, or first pick. Beats the appearance of favoritism from any human-imposed order.
  • Roll multiple D20 for tabletop RPG advantage/disadvantage. Set dice to D20, quantity to 2. Under advantage rules, take the higher result; under disadvantage, take the lower. Rolling 2d20 like this correctly simulates both rules.
  • Generate in batches to see distribution over time. Generate 100 numbers from 1–10 using Multiple mode. You should see each number appear roughly 10 times, but rarely exactly 10 — actual frequency for any single value will typically fall between 5 and 15 per 100 draws. If you see a perfectly even distribution, that would actually be suspicious of a non-random generator.

Frequently Asked Questions — Random Number Generator

This tool uses window.crypto.getRandomValues() — the browser's cryptographically secure random number generator. It draws entropy from hardware sources (CPU timing jitter, hardware noise registers) and is considered genuinely unpredictable, unlike Math.random() which is a deterministic algorithm. The result is indistinguishable from true randomness for any practical purpose, including security-sensitive applications.
Streaks are normal in true randomness — they're actually evidence that the generator is working correctly. Rolling the same number three times in a row on a D6 has a probability of (1/6)³ = 0.46%, which sounds rare but happens in roughly 1 out of every 216 three-roll sequences. Over hundreds of rolls, you will see every kind of cluster. A generator that "avoided" repeats would be less random, not more. If you need guaranteed variety, use Multiple mode with "no duplicates" enabled.
Up to 500 numbers per batch in Multiple mode. With "no duplicates" enabled, the quantity can't exceed the size of your range — you can't generate 10 unique numbers from a 1–5 range (only 5 unique values exist). If this happens, the tool will generate as many unique values as the range allows. For very large unique sets (1,000+ numbers), use the List Shuffle mode instead — shuffle a pre-built list of sequential numbers for perfect uniqueness at any scale.
Yes — use Multiple mode, set min/max to match your lottery's range, set quantity to the number of balls drawn, and enable "no duplicates." For Powerball, you'd generate 5 numbers from 1–69 separately from 1 number from 1–26. This is exactly how quick-pick machines at retailers work. No combination has better odds than any other, so random picks are as valid as any deliberate strategy — and they avoid the birthday-number bias that most manual pickers have.
The birthday problem asks: in a group of n people, what's the probability that at least two share a birthday? The answer surprises most people — with just 23 people, the probability is 50.73%. With 57 people it's 99.01%. This matters for random numbers because it shows how often "collisions" (two draws producing the same value) occur even in genuinely random sequences. When generating random IDs or tokens, you need to account for collision probability — a 6-digit code (1,000,000 possibilities) has a 50% collision chance after only about 1,177 codes are generated.
The list shuffle uses the Fisher-Yates algorithm — the gold standard for unbiased shuffling. It works by iterating through the list from the last item to the first, swapping each item with a randomly chosen earlier item. Every permutation of n items has exactly equal probability of 1/n!. For a 10-item list that's 1 in 3,628,800. A naive shuffle (picking random positions and swapping) produces biased results where some orderings are more likely — Fisher-Yates avoids this completely.