Random Number Generator

Set your range and click Generate for a random whole number.

How Random Number Generator Works

This tool picks one random whole number from a range you set, using your browser's built-in random number generator. It's built for quick, everyday randomness -- picking a winner, rolling a virtual die, breaking a tie -- rather than for cryptographic or gambling-grade security.

Formula & Method

The calculator uses JavaScript's Math.random() to produce a number, which it scales to your chosen range with min + Math.floor(Math.random() × (max − min + 1)). This means every whole number between your minimum and maximum -- inclusive of both endpoints -- has an equal chance of being picked. If you happen to enter a minimum larger than the maximum, the tool automatically swaps the two values before generating.

Worked Example

With the default range of 1 to 1000, there are 1000 possible values (1000 − 1 + 1 = 1000), each equally likely -- so any single number has a 1-in-1000 chance of coming up. If you narrowed the range to, say, 1 to 6 to simulate a die roll, there would be exactly 6 equally likely outcomes.

Frequently Asked Questions

Is the generated number truly random?
It's pseudo-random, generated by your browser's Math.random() function. That's more than good enough for everyday uses like raffles, games, or picking a sample -- but it isn't a cryptographically secure source of randomness, so it shouldn't be used for security keys, passwords, or real-money gambling.
Can the same number come up twice in a row?
Yes. Each click is an independent draw, so repeats are possible and expected over enough tries -- just like rolling a die can show the same face twice in a row.
Are the minimum and maximum values included as possible results?
Yes, both endpoints are included. A range of 1 to 10 can produce 1 or 10 themselves, not just the numbers in between.
What happens if I enter a minimum that's bigger than the maximum?
The tool automatically swaps the two values so the range is always valid, then generates a number from the corrected range -- you don't need to fix the order yourself.
Click Generate to get started