Random Number Generator

Pick a random whole number between any minimum and maximum, both included, from the browser's crypto generator with no modulo bias. Presets for 1-10 and 1-100.

The interactive tool loads here when JavaScript runs.

About this tool

What is the Random Number Generator?

Enter a minimum and a maximum, click Generate Random Number and, after a short drum-roll, one whole number from that range appears. Both ends are included, so 1 to 6 behaves like a die and 1 to 100 can return 100.

Presets fill common ranges in one click: 1-10, 1-100, 1-1000 and 0-1 (a coin flip). The result card shows the range, how many values were possible and whether the number is even or odd, with a button to copy it. Fullscreen mode makes the result readable across a room for raffles and classroom draws.

Numbers come from crypto.getRandomValues, the browser's cryptographically secure generator, and are drawn in your browser. The tool produces one number per click; for a list of unique picks, use the Random Picker or Group Splitter.

  • Inclusive minimum and maximum
  • Crypto-strength randomness with rejection sampling, no modulo bias
  • Ranges up to 2^53 and negative numbers
  • One-click presets and a fullscreen display
  • Even/odd and total-possibilities details
Read the guide: Random Numbers, Names and Emails for Test Data, Done Properly

Updated

How to use the Random Number Generator

  1. Type a Minimum Value and a Maximum Value, or click a preset such as 1-100.
  2. Click Generate Random Number.
  3. Read the result and the Number Details: range, total possibilities and even or odd.
  4. Click Copy Number to copy it, or Generate Another to go back to the settings.

Worked examples

Dice roll

Input

Minimum 1, Maximum 6

Output

Any of 1, 2, 3, 4, 5 or 6, each with probability 1/6

Both bounds are included, so Total possibilities shows 6.

Why rejection sampling matters

Input

Range of 3 values

Output

Draws of 4294967295 are rejected and redrawn

2^32 is not a multiple of 3, so the top value would otherwise map to an extra copy of one result. Discarding it keeps the three outcomes exactly equal.

Background and insight

Turning random bits into a number in a range is easy to get subtly wrong. The obvious method, random32 % range, is biased whenever the range does not divide 2^32 evenly: some results get one extra chance. For a range of 3, the bias is tiny; for ranges near 2^31 it approaches 2 to 1. This tool uses rejection sampling, the method behind Java's nextInt(bound) and Python's secrets.randbelow: any draw above the largest multiple of the range is discarded and redrawn, so every value has exactly the same probability.

Math.random() is fine for games, but it is a fast pseudo-random generator (xorshift128+ in V8) whose future output can be predicted from enough past output. crypto.getRandomValues draws from the operating system's CSPRNG, which is what you want when the result decides who wins something. Ranges up to 2^53, the largest span a JavaScript number can count exactly, are supported.

Random does not mean evenly spread in small samples. Ten rolls of 1 to 10 will usually repeat at least one number: the chance of ten distinct values is 10!/10^10, about 0.036%. Streaks and repeats are what fair randomness looks like.

Common use cases

  • Raffles and giveaways

    Number the entries, set the range to match, and draw a winner on a fullscreen display.

  • Games and classrooms

    Roll a die of any size, pick a question number or choose a student by register number.

  • Sampling and testing

    Pick a random row, port or ID to spot-check without choosing it yourself.

  • Breaking ties

    Settle a decision between numbered options with an unbiased draw.

Tips and limitations

  • Only whole numbers are accepted. Decimal or out-of-range inputs show an error rather than being silently truncated.
  • The minimum must be smaller than the maximum. Negative ranges such as -10 to 10 work.
  • Each click is independent, so the same number can come up twice in a row.
  • For lottery-style draws of several unique numbers, use the Random Picker with a list, since this tool returns one number at a time.

Sources and further reading

  1. Crypto: getRandomValues() method, MDN Web Docs. The browser's cryptographically strong random source
  2. There's Math.random(), and then there's Math.random(), V8. Why V8 switched Math.random to xorshift128+
  3. secrets: Generate secure random numbers for managing secrets, Python Software Foundation. secrets.randbelow
  4. Random (Java SE 21), Oracle. nextInt(bound) and its rejection loop

Frequently asked questions

Is the maximum value included in the random number range?

Yes. Both the minimum and the maximum can be drawn. A range of 1 to 100 has 100 possible results, and the Number Details panel shows that count. Many programming functions exclude the upper bound, so this is worth checking when you compare results with code.

Is this random number generator truly random?

It uses crypto.getRandomValues, the browser's cryptographically secure generator seeded by the operating system. That is unpredictable enough for draws, raffles and security-sensitive picks. It is not a hardware true-random source, but in practice the difference is not observable.

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

Click the 1-10 preset, or type 1 as the minimum and 10 as the maximum, then click Generate Random Number. Each of the ten values has exactly a one-in-ten chance on every click.

Why did the same number come up twice?

Because every draw is independent. With a 1 to 10 range, the chance the next number matches the last one is 10%. Repeats and short streaks are normal in fair random sequences; a generator that avoided them would be less random, not more.

Can I generate several unique random numbers at once?

Not on this page; it returns one number per click. To draw several values without repeats, put the numbers or names in the Random Picker, or use the Group Splitter to shuffle a list into groups.

What is modulo bias in random number generation?

It is the unevenness you get from random % n when n does not divide the generator's range. Some results get an extra chance. This tool avoids it with rejection sampling: draws that fall in the uneven tail are thrown away and redrawn.

Is there an in-depth guide to the Random Number Generator?

Yes. “Random Numbers, Names and Emails for Test Data, Done Properly” covers the background, how it works, common pitfalls and worked examples. Read the full guide.