Random Number Generator
Generate random whole numbers in any range, with a choice of how many and an option to draw without duplicates. Runs entirely in your browser.
What this random number generator does
This tool draws whole numbers at random from a range you choose. Both ends are inclusive: a range of 1 to 100 can return 1 and can return 100. You can draw a single number, or up to 1000 at once, and you can choose whether the draw allows duplicates or picks each number at most once.
Randomness comes from window.crypto.getRandomValues, the browser's cryptographically secure random
number generator. Nothing is generated on a server, nothing is seeded from the clock, and nothing you enter leaves
the page — the numbers exist only in the tab you are looking at and are gone when you reload. If a very old
browser does not provide getRandomValues, the tool falls back to Math.random and says so
on screen, because Math.random is not designed to be unpredictable.
How to use it
- Set the minimum and maximum. Negative numbers are fine, and so is a range of one value, where the answer is simply that value.
- Set how many numbers you want. One is a single draw; six is a lottery line; 50 is a sample.
- Turn on No duplicates for a draw where each number can appear once — raffle tickets, lottery numbers, picking winners from a numbered list. Leave it off for independent draws such as dice rolls, where repeats are expected and normal.
- Optionally sort the results, and pick how they are separated, then copy the list.
Every change regenerates immediately, and Generate again redraws without changing any setting.
How to read the result
A single draw is shown as one large number. A draw of two or more is shown as a list, with the lowest value, the highest value, the sum and the mean underneath. Those summaries describe this draw only — they are not a property of the range, and they will move every time you redraw. That is the point: a fair generator produces an uneven-looking sample. Rolling a die six times rarely gives you each face once, and a run of three 5s in twenty draws is unremarkable rather than evidence of a broken generator.
Uniform, and why the maths matters
A draw is uniform when every value in the range is equally likely, with probability 1 ÷ (max − min + 1). In a 1-to-100 range that is 1% per number.
Getting there takes a little more than one line of code. The browser hands out random 32-bit integers — values from 0 to 4,294,967,295 — and the obvious trick of taking the remainder modulo the range size introduces modulo bias whenever the range does not divide 232 evenly: the low values of the range get one extra chance each, and are slightly more likely than the high ones. This tool instead takes the smallest number of random bits that covers the range and discards any value that lands above it, redrawing until one falls inside. That is called rejection sampling; it costs an occasional extra draw and returns an exactly uniform result. Ranges wider than 232 values are assembled from two 32-bit words.
For a draw with no duplicates, picking numbers one at a time and throwing away repeats gets slow as the draw fills the range. This tool uses a partial Fisher-Yates shuffle instead, recording only the positions it actually swaps, so drawing 6 unique numbers from a range of a billion takes six steps rather than a billion. Each possible set and ordering is equally likely.
Worked example
Say you want a lottery line: six numbers from 1 to 49, no duplicates, sorted. The range holds 49 − 1 + 1 = 49 whole numbers, so the first pick has a 1-in-49 chance of being any given number, the second has 1 in 48 among the numbers left, and so on.
- Entering min 1, max 49, count 6 with No duplicates on returns a list such as 3, 11, 17, 28, 36, 44 — a different one each time you press Generate again.
- The number of distinct unordered sets of 6 from 49 is C(49, 6) = 13,983,816, so any particular line comes up with that probability.
- Turn No duplicates off and the same inputs model six independent draws, where the chance of at least one repeat is about 28% — the birthday problem in miniature.
Edge cases this tool refuses
- Minimum above maximum. The generator stops and asks you to swap them rather than returning an empty or nonsensical answer.
- A range with no whole number in it. Decimal bounds are pulled inward to whole numbers — the minimum rounds up, the maximum rounds down — so 2.5 to 2.9 contains nothing to draw and says so.
- More unique numbers than the range holds. Asking for 50 distinct numbers between 1 and 10 is impossible; the tool names the limit instead of looping forever or silently repeating values.
- Empty or non-numeric input is treated as missing rather than as zero, and a count below 1 is
rejected. Nothing here can return
NaN. - Very large bounds are clamped to ±1,000,000,000,000, which keeps every range inside the exact-integer limit of JavaScript numbers.
What this is and is not good for
Because the numbers come from the browser's cryptographic generator, they are suitable for raffles, sampling, shuffling, games, test data and picking winners. Two caveats worth stating plainly:
- It is not an audited draw. Nothing here is recorded, timestamped or witnessed, so for a prize draw that someone might dispute you want a procedure that produces evidence, not just a number on a screen.
- It is not a seeded generator. There is no way to reproduce a previous draw, by design. If you need repeatable randomness for a simulation, you want a pseudo-random generator with a seed you control.
True randomness, in the physical sense, comes from measuring something unpredictable in the world. What a browser gives you is a cryptographically secure pseudo-random stream: the operating system collects entropy from hardware events and stretches it with a cipher, so the output is computationally indistinguishable from random even to someone who has seen all of it so far.