Random Number Generator -- Integers, Dice & More

Generate random numbers within any range, with options for uniqueness, sorting, and multiple draws

Generate Random Numbers

Pick random integers within any range using cryptographically secure randomness. Both min and max are included. Useful for dice rolls, lottery picks, random sampling, games, and decision-making.

Result
Press Generate
Range: 1 - 100
How many
numbers (1-200)

Common Use Cases

Click a scenario to load it into the generator

Roll a Die

1 number from 1-6. Classic six-sided die roll.

Flip a Coin

0 or 1. Heads or tails decision.

Lottery Numbers

6 unique numbers from 1-49. No repeats, sorted.

Raffle Draw

5 unique numbers from 1-500. Pick winners.

Random PIN

4 digits from 0-9. Quick PIN generation.

D20 Roll

1 number from 1-20. Tabletop RPG roll.

Random Percentage

1 number from 0-100. Random percentage value.

Random Sample

10 unique from 1-1000. Statistical sampling.

How This Random Number Generator Works

This tool generates random integers using the Web Crypto API (crypto.getRandomValues()), which provides cryptographically secure pseudorandom numbers. Here is the process:

  1. Request entropy: The browser calls the operating system's cryptographic random number generator, which collects entropy from hardware events (mouse movements, key timing, disk I/O, interrupt timing).
  2. Generate raw bytes: The OS returns random bytes that are unpredictable even if an attacker knows all previous outputs.
  3. Map to your range: The raw random value is mapped uniformly to your chosen range [min, max] using rejection sampling to avoid modulo bias.
  4. Apply constraints: If "no repeats" is enabled, previously drawn numbers are excluded from subsequent picks.
  5. Display results: Numbers are shown immediately -- nothing is sent to any server.

Why Crypto Randomness Matters

Older random number generators (like Math.random() in JavaScript) use algorithms that are fast but predictable. If someone knows the internal state, they can predict every future output. Cryptographic RNGs are designed so that even with knowledge of previous outputs, the next value cannot be predicted.

Property Math.random() crypto.getRandomValues()
Algorithm xorshift128+ (varies by engine) OS-level CSPRNG (e.g., ChaCha20, AES-CTR-DRBG)
Predictable? Yes, if state is known No (computationally infeasible)
Entropy source Seed from system clock or similar Hardware interrupts, timing jitter, device noise
Speed Faster Slightly slower (still microseconds)
Use cases Animations, non-critical UI Games, drawings, security, sampling

Understanding Uniform Distribution

This generator produces uniformly distributed random integers. That means every integer in the range has exactly the same probability of being chosen.

Equal Probability

In a range of 1-10, each number has a 10% chance. In 1-100, each has a 1% chance. No number is "more likely" or "due" to appear.

Independence

Each draw is independent of previous draws (unless "no repeats" is on). Getting 7 three times in a row does not make 7 less likely next time. This is a common misconception called the gambler's fallacy.

No Modulo Bias

Naive implementations use random % range, which slightly favors lower numbers if the range doesn't divide evenly into the source. This tool uses rejection sampling to eliminate modulo bias.

Examples

Simulating Dice

Range: 1-6 for a standard die, 1-20 for a D20, 1-8 for a D8. Generate multiple rolls at once for tabletop games.

Random Student Selection

Number students 1-30, then generate one random number to pick who presents next. Fair and transparent.

Lottery-Style Draws

Range: 1-49 (or your local lottery range). Count: 6. Enable "no repeats." Each combination is equally likely.

Random Sampling

Assign numbers 1-1000 to items in a dataset. Generate 50 unique random numbers to select a sample for analysis.

Game Development

Generate random damage values (e.g., 10-25), spawn positions, loot drops, or event triggers.

Random Order / Shuffling

Generate N unique numbers from 1-N to create a random ordering. Useful for randomizing presentation order or playlist shuffling.

Common Mistakes

  • Gambler's fallacy: Believing a number is "due" because it hasn't appeared recently. Each draw is independent -- previous results have no effect on future ones.
  • Confusing range boundaries: Some generators exclude the maximum (e.g., random(1, 10) gives 1-9). This tool includes both endpoints: 1 and 10 are both possible results.
  • Requesting more unique numbers than the range allows: You cannot draw 20 unique numbers from a range of 1-10. The "no repeats" option enforces this limit automatically.
  • Using non-secure RNG for fairness-critical draws: Math.random() is fine for casual use but should not be used for competitions, giveaways, or anything where unpredictability matters. This tool uses crypto.getRandomValues().
  • Expecting patterns in small samples: If you generate 10 numbers from 1-100, it's normal to see clusters and gaps. Uniform distribution becomes visibly smooth only over many thousands of draws.
  • Modulo bias: Using Math.floor(Math.random() * N) can slightly favor some numbers if N isn't a power of 2. This tool avoids that with rejection sampling.

Frequently Asked Questions

How does a random number generator work?

A random number generator (RNG) produces numbers that have no predictable pattern. This tool uses the Web Crypto API (crypto.getRandomValues()), which draws from your operating system's cryptographic random source -- the same source used for encryption keys and secure tokens. Each integer in your chosen range has an equal probability of being selected.

Is this random number generator truly random?

This tool uses cryptographically secure pseudorandom number generation (CSPRNG) via the browser's Web Crypto API. It is backed by your operating system's entropy pool, which collects unpredictable data from hardware events like mouse movements, key timing, and interrupt signals. While technically pseudorandom (only quantum sources are "truly" random), it is considered cryptographically secure and is indistinguishable from true randomness for all practical purposes.

What is the difference between Math.random() and crypto.getRandomValues()?

Math.random() uses a fast pseudorandom algorithm (typically xorshift128+) that is predictable if the internal state is discovered. crypto.getRandomValues() uses a cryptographically secure source seeded by OS-level entropy. Use Math.random() for non-critical tasks like animations. Use crypto.getRandomValues() when fairness or unpredictability matters -- games, drawings, lottery picks, security tokens.

How do I generate a random number between 1 and 100?

Set the minimum to 1 and the maximum to 100, then click Generate. Both 1 and 100 are included in the range. Each integer from 1 to 100 has an equal 1% chance of being selected.

Can I generate random numbers with no repeats?

Yes. Enable the "Unique (no repeats)" toggle. The generator will produce a set of distinct numbers -- no duplicates. This is called "sampling without replacement." Note: the count cannot exceed the range size. You cannot draw 20 unique numbers from a range of 1-10.

What is uniform distribution?

Uniform distribution means every possible outcome has the same probability. In a range of 1-10, each number has a 10% chance. This is different from normal (bell curve) distribution where values near the center are more likely, or exponential distribution where smaller values are more likely. This tool generates uniformly distributed integers.

Can I use this for lottery numbers?

You can use this tool to generate random numbers in any range, which works for picking lottery-style numbers. Enable "Unique (no repeats)" and set your range and count to match your lottery format (e.g., 6 numbers from 1-49). Keep in mind: no tool can improve your odds of winning. Every valid combination has the same probability.

Is this suitable for scientific random sampling?

For basic random sampling -- selecting random participants, randomizing experimental groups, picking items from a dataset -- this tool is appropriate. It uses a cryptographically secure source with uniform distribution. For advanced statistical work requiring specific distributions, reproducible seeds, or very large sample sizes, use a statistical package like R, Python's NumPy, or similar.

What is the gambler's fallacy?

The gambler's fallacy is the mistaken belief that past random outcomes affect future ones. For example, believing that after rolling 6 three times in a row, the next roll is "less likely" to be 6. In reality, each roll is independent -- the probability stays 1/6 regardless of history. This applies to all independent random events: coin flips, lottery draws, roulette spins.

What is modulo bias?

Modulo bias occurs when using the remainder operator (%) to map random bytes to a range. If the range size doesn't divide evenly into the source's range, some outputs are slightly more probable than others. For example, mapping a random byte (0-255) to 1-100 using byte % 100 makes numbers 1-56 slightly more likely than 57-100. This tool uses rejection sampling to eliminate modulo bias entirely.

Does this tool store my data?

No. All random number generation happens in your browser using JavaScript. Nothing is sent to any server. No inputs, results, or draw history are stored or logged. You can verify this by using the tool offline after the page loads.

Related Tools

Privacy & Limitations

  • Client-side only. No data is sent to any server. No cookies, no tracking of inputs or results.
  • Cryptographically secure. Uses crypto.getRandomValues() (Web Crypto API) backed by your OS entropy pool. Suitable for fair drawings and competitions.
  • Integer and decimal. Toggle decimal mode for 2-decimal-place results, or keep integer mode for whole numbers.
  • Maximum 200 numbers per draw. For larger datasets, use a programming language with a cryptographic RNG library.
  • Not a hardware RNG. While cryptographically secure, this is a pseudorandom generator seeded by hardware entropy. For applications requiring certified true randomness (e.g., regulatory compliance), use a hardware random number generator.

Related Tools

View all tools

Random Number Generator FAQ

How does a random number generator work?

A random number generator (RNG) produces numbers that have no predictable pattern. This tool uses the Web Crypto API (crypto.getRandomValues), which draws from your operating system's cryptographic random source — the same source used for encryption keys and secure tokens. Each integer in your chosen range has an equal probability of being selected.

Is this random number generator truly random?

This tool uses cryptographically secure pseudorandom number generation (CSPRNG) via the browser's crypto.getRandomValues() API. It is backed by your operating system's entropy pool, which collects unpredictable data from hardware events. While technically pseudorandom, it is considered cryptographically secure and suitable for any non-hardware-RNG use case.

What is the difference between Math.random() and crypto.getRandomValues()?

Math.random() uses a pseudorandom algorithm (typically xorshift128+) that is fast but predictable if the internal state is known. crypto.getRandomValues() uses a cryptographically secure source seeded by OS-level entropy (e.g., hardware interrupts, timing jitter). Use Math.random() for non-critical tasks like animations. Use crypto.getRandomValues() when fairness or unpredictability matters — games, drawings, security tokens.

How do I generate a random number between 1 and 100?

Set the minimum to 1 and the maximum to 100 in the generator above, then click Generate. Both 1 and 100 are included in the range. Each integer from 1 to 100 has an equal 1% chance of being selected.

Can I generate random numbers with no repeats?

Yes. Check the 'No repeats (unique)' option. The generator will ensure every number in the result is different. This is useful for lottery draws, random sampling, and assigning unique IDs. Note: the count cannot exceed the range size when this option is enabled.

What is uniform distribution?

Uniform distribution means every possible outcome has the same probability. In a random number generator with range 1-10, each number has a 10% chance of appearing. This is different from normal (bell curve) distribution where values near the mean are more likely. This tool generates uniformly distributed random integers.

Can I use this for lottery numbers?

You can use this tool to generate random numbers in any range, which works for picking lottery-style numbers. Enable 'No repeats' and set your range to match the lottery format (e.g., 1-49 for 6 numbers). Note: no tool can improve your odds of winning — every valid combination has the same probability.

Is this suitable for scientific random sampling?

For basic random sampling (selecting random participants, randomizing order), this tool is appropriate. It uses a cryptographically secure source with uniform distribution. For advanced statistical needs requiring specific distributions (normal, Poisson, etc.) or reproducible sequences with a seed, use a statistical software package.

Does this random number generator store my data?

No. All random number generation happens in your browser using JavaScript. Nothing is sent to any server. No inputs, results, or history are stored or logged.

What is the maximum range I can use?

This tool supports any integer range within JavaScript's safe integer limits (−9,007,199,254,740,991 to 9,007,199,254,740,991). For practical use, any range you would realistically need is supported.

Request a New Tool
Improve This Tool