Random Number Generator
Generate a uniformly random integer between a minimum and maximum value (inclusive). Useful for raffles, sampling, games, and quick lottery picks.
Last updated: September 2026
Compare with similar
About this calculator
A random number generator (RNG) returns a value drawn uniformly from a specified range, meaning every integer between the minimum and maximum is equally likely. This calculator uses the browser's built-in pseudorandom number generator, which is fine for casual use (games, raffles, picking a name) but is not cryptographically strong — do not use it to generate passwords, keys, or lottery tickets that are legally binding.
The formula floor(random() * (max - min + 1)) + min maps a uniform real in [0, 1) into an integer in [min, max]. The +1 inside the floor is what makes max reachable; without it, max would appear with probability zero.
Because each result is independent, patterns will happen. In a sequence of 20 picks from 1–10, you should expect the same number twice; that is not a bug in the RNG. If a genuinely 'random-looking' sequence is what you need — with no repeats — you want a shuffle, not an RNG.
How to use
Example — pick a number 1 to 100. Set Minimum = 1, Maximum = 100. Each recompute the calculator returns a fresh integer, e.g. 47. Verify the bounds: min = 1 and max = 100 are both reachable and every value in between has probability 1/100 ≈ 1%. Example — coin flip. Set Minimum = 0, Maximum = 1. Half the time you get 0 (say 'tails'), half the time 1 ('heads'). This is equivalent to the standalone dice roller at /en/calculators/gaming/dice-roller/ with sides = 2.
Frequently asked questions
Are these numbers truly random?
No — they are pseudorandom. The browser's Math.random() returns values from a deterministic sequence seeded by the process state, so it looks random for practical purposes but is predictable to an attacker who knows the seed. For gambling, cryptography, or any adversarial use, use a cryptographically secure RNG such as crypto.getRandomValues() (in browsers) or /dev/urandom.
How do I generate several numbers at once, without repeats?
This tool returns one number per recompute; there is no built-in 'without replacement' mode. For a small sample, run the calculator a few times and skip duplicates. For a shuffled draw (like 6 unique lottery numbers from 1–49), it is faster to fill an array with 1..49 and shuffle it — the Fisher-Yates shuffle is the standard way, and every ordering is equally likely.
Why does the number sometimes repeat?
Every draw is independent, so repeats are expected. In 100 rolls of 1–10 you should on average see about 4.5 pairs of identical adjacent values (birthday-style math). Absence of repeats over a long run would actually be evidence of a broken RNG.
What if I set min > max?
The formula still returns a number, but the range is empty and the result is meaningless. Convention is to enter min ≤ max. The calculator does not swap them automatically because 'roll d(-6)' is almost certainly a typo, not a valid request.