What this tool returns
Enter a minimum and a maximum and the generator returns one whole number from that range, counting both ends. With 1 and 6 you get a die roll, six possible results, each equally likely. With 1 and 100 you get a percentage. It never returns a decimal, so it is the wrong tool for a random price or a random coordinate; multiply and divide to get those.
Every press is an independent draw. There is no memory of what came before, so seeing 42 twice in a row is not a bug, it is what independent draws look like. If the minimum is larger than the maximum the two values are swapped, so the order you type them in does not matter, and negative ranges work the same way.
Why the inclusive range matters
Getting the arithmetic right is where most hand-written snippets fail. The correct formula for an inclusive integer range is floor of random multiplied by the width, where the width is the maximum minus the minimum plus one, and then add the minimum. That plus one is what makes the top value reachable at all. A common alternative, rounding random multiplied by the maximum, gives the two end values only half the probability of everything between them. The bias is invisible in ten draws and obvious in a raffle with a thousand entries.
This generator uses the floor form with the full width, so every integer in the range has a probability of one divided by the number of values. That uniformity is exactly what dice, lotteries, sampling and randomised ordering need.
Where ordinary randomness is not enough
The draw comes from Math.random, which is fine for games, classroom picks, deciding which test case to run first, or shuffling a playlist in a demo. It is not suitable for anything an attacker could profit from guessing, such as a one-time code, a prize draw with money attached, or a token that unlocks an account, because the sequence is predictable once enough of it is observed. For those, use a generator built on crypto.getRandomValues, which is seeded from the operating system and cannot be extrapolated from earlier values.
If what you need is a unique identifier rather than an arbitrary number, a UUID is a better fit: it is 128 bits wide, so collisions are not a practical concern, and its version bits tell any library what it is. A random number between 1 and a million will collide once you hold a few thousand records. When the identifier has to read as words rather than digits, the slug generator builds a URL-safe string from a title.
An example: drawing a raffle winner
You have sold 240 tickets numbered 1 to 240 and need a first-prize winner for a live stream. Set the minimum to 1, the maximum to 240, and click once. Because both ends are included, ticket 1 and ticket 240 have the same chance as every number in between; a tool that excluded the maximum would quietly give the last buyer no chance at all. For second and third prize you can click again, but a second click can repeat the first winner, since the draws are independent. To draw without replacement, generate a batch of numbers, paste them into the duplicate line remover, and announce only values that survived.
