Random Number Generator
Pick a random integer between any minimum and maximum — every number in the range has an equal chance.
Random Number Generator
Each number in the range has exactly the same probability. The generator uses your browser's cryptographic random source (crypto.getRandomValues), not a predictable seed.
Formula:
value = min + floor(random × (max − min + 1)), where random is a uniform fraction in [0, 1).
Each of the (max − min + 1) numbers in the range has probability 1 ÷ (max − min + 1). For 1 to 100, that is 1% each.
What Does a Random Number Generator Do?
A random number generator picks an integer between a minimum and a maximum, with every number in the range having exactly the same chance of being chosen. Set the range — 1 to 100, 1 to 6 for a die, 1 to 1,000 for a raffle — and press Generate. The result appears immediately, along with the size of the range and the probability of any single number.
Random numbers are useful wherever a fair, unbiased choice is needed: drawing raffle winners, picking a name from a list, rolling dice for a game, deciding who goes first, generating a random sample for a survey, or choosing a random item from a collection. The key property is fairness — no number is favored over any other — and this generator is built to guarantee it.
How to Use This Generator
Enter the minimum and the maximum of the range, then press Generate Random Number. The result is a whole number between the two, inclusive of both ends: a range of 1 to 100 can produce 1, 100, or anything in between. Changing the range generates a new number automatically, and pressing the button again generates another.
The rows underneath show the range, how many numbers are in it, and the chance of any one number being picked. For the default range of 1 to 100, there are 100 numbers and each has a 1% chance. For a range of 1 to 6, there are 6 numbers and each has a 16.67% chance — the same as rolling a fair die.
How the Randomness Works
The generator uses your browser's cryptographic random source,
crypto.getRandomValues, which draws from the operating
system's entropy pool — the same source used to generate encryption
keys. It produces a uniform fraction between 0 (inclusive) and 1
(exclusive), and the formula value = min + floor(random × (max
− min + 1)) maps that fraction onto the range. Because the
fraction is uniform, every number in the range has the same
probability: 1 divided by the number of numbers in the range.
The "+ 1" in the formula is important: a range from 1 to 100 contains 100 numbers, not 99. Without it, the maximum could never be generated. And the floor operation is what makes the distribution uniform — each integer gets an equal slice of the [0, 1) interval, exactly 1/100 wide for a range of 100 numbers.
This is a better source of randomness than the common
Math.random(), which is a pseudorandom generator with a
seed that can in principle be predicted. For picking raffle winners or
rolling dice, either would do — but cryptographic randomness costs
nothing extra and removes any doubt about fairness.
Worked Example: A Raffle and a Die Roll
Say you are running a raffle with 250 tickets numbered 1 to 250. Set the range to 1 to 250 and press Generate. Suppose the result is 137 — ticket 137 wins. Every ticket had a 1 in 250 chance, which is 0.4%. If you need three winners, generate three times; if a number repeats, generate again for that prize, since a ticket cannot win twice. The chance of a repeat on the second draw is 1 in 250 (0.4%), and on the third draw it is 2 in 250 (0.8%) — small, but it happens.
For a die, set the range to 1 to 6. Each face has a 1 in 6 chance, which is 16.67%. Roll twice by generating twice: the chance of rolling two sixes in a row is 1/6 × 1/6 = 1/36, about 2.78%. The chance of rolling at least one six in two rolls is 1 − (5/6 × 5/6) = 1 − 25/36 = 11/36, about 30.56%. These are the same odds as physical dice, because the generator is uniform.
Probability of a Range
The chance of any single number is 1 divided by the count of numbers in the range. Here are some common ranges:
- 1 to 2 (a coin flip): 2 numbers, 50% each
- 1 to 6 (a die): 6 numbers, 16.67% each
- 1 to 10: 10 numbers, 10% each
- 1 to 20 (a d20 in tabletop games): 20 numbers, 5% each
- 1 to 100: 100 numbers, 1% each
- 1 to 1,000: 1,000 numbers, 0.1% each
- 0 to 9 (a single digit): 10 numbers, 10% each
Negative ranges work the same way. A range from −10 to 10 contains 21 numbers (10 negative, zero, and 10 positive), so each has a 1 in 21 chance, about 4.76%. The minimum must be less than or equal to the maximum — if you enter them the other way around, the generator tells you to swap them.
True Randomness vs Pseudorandomness
Computers cannot generate true randomness from arithmetic alone — a
formula always produces a predictable sequence if you know the starting
point (the seed). Pseudorandom generators like Math.random()
are fine for games and simulations, but they are deterministic: the
same seed always produces the same sequence. Cryptographic generators
like the one used here seed from physical entropy — timing jitter,
hardware noise, and other unpredictable events collected by the
operating system — so the sequence cannot be predicted or reproduced.
For most purposes the distinction does not matter. But for anything where fairness could be questioned — a raffle with real prizes, a random draw for a limited resource — a cryptographic source is the right choice, because no one can argue the result was rigged by choosing a favorable seed. The numbers are also generated entirely in your browser: nothing is sent to a server, so the result is private.
Tips for Fair Draws
Generate in front of witnesses. For a raffle or a draw, run the generator where everyone can see the screen. Transparency is what makes a random draw trusted, not just the randomness itself.
Re-draw repeats. If you need distinct winners, generate again when a number repeats. The chance of a repeat is small for large ranges but real — for 3 draws from 250 tickets, the chance of at least one repeat is about 1.2%.
Use the right range. If tickets are numbered from 0, set the minimum to 0 — a range of 1 to 250 cannot pick ticket 0. If names are on a numbered list, use the list positions as the range.
Do not re-roll to get a "better" result. Re-rolling until you like the answer destroys the fairness. Decide the rules before generating: one draw, first result counts.
Common Mistakes to Avoid
The biggest mistake is the off-by-one error: forgetting that the range is inclusive of both ends. A range of 1 to 100 has 100 numbers, not 99, and a range of 0 to 9 has 10 numbers. If you want a random digit, use 0 to 9, not 1 to 9 — the latter can never produce 0.
The second mistake is expecting random numbers to look random. True randomness produces streaks and clusters: in 100 coin flips, a run of 5 heads in a row is likely, and in 100 die rolls, some number will come up noticeably more often than others. That is not bias — it is what randomness looks like. A sequence with no streaks at all is suspicious, not fair.
The third mistake is using a random number generator for security — passwords, tokens, or lottery numbers. This tool is for casual fairness, not cryptography. For security purposes, use a dedicated password generator or your operating system's random facilities, and never use a website's output as a secret.
Frequently Asked Questions
How do I generate a random number between 1 and 100?
Set the minimum to 1 and the maximum to 100, then press Generate. Each number from 1 to 100 has an equal 1% chance of being picked.
Is this random number generator fair?
Yes. It uses the browser's cryptographic random source (crypto.getRandomValues) and a uniform formula, so every number in the range has exactly the same probability: 1 divided by the count of numbers in the range.
Can I generate a random number between negative numbers?
Yes. A range from -10 to 10 contains 21 numbers (including zero), so each has a 1 in 21 chance, about 4.76%. Just enter a negative minimum.
What is the chance of rolling two sixes in a row?
1 in 36, about 2.78%. Each die has a 1 in 6 chance of a six, and the two rolls are independent, so 1/6 x 1/6 = 1/36.
Why did I get the same number twice in a row?
Because each draw is independent. In a range of 1 to 100, the chance of repeating the previous number is 1% on every draw — the generator has no memory. Streaks and repeats are normal in true randomness.