Pick a range, say how many numbers you want, and generate. Two things separate this from the usual implementation. The numbers come from crypto.getRandomValues, the browser's cryptographic generator, not Math.random — whose output is predictable from earlier values and which the specification itself says not to use for anything that matters. And the range is handled without modulo bias: taking one random value modulo the range, which is what almost everything does, makes lower numbers slightly more likely unless the range happens to divide evenly. Unusable draws are rejected and redrawn instead, which costs an occasional extra draw and makes every outcome exactly equally likely. Options cover decimals, no-repeats, exclusions and sorting. Nothing is generated on a server, so no result is ever recorded.
| Approach | Distribution |
|---|---|
| Math.random × range | Predictable source, uneven at the edges |
| Random 32-bit % range | Low values slightly more likely |
| Reject and redraw | Exactly uniform — what this uses |
It uses crypto.getRandomValues, which draws from the operating system's entropy pool — the same source used for cryptographic keys. That is as close to unpredictable as software gets, and far better than Math.random, whose future output can be reconstructed from past values.
The common shortcut is to take a random 32-bit number and apply modulo the range. Unless the range divides 2^32 exactly, the leftover at the top wraps back onto the start, so the lowest values come up slightly more often. For a dice roll this is invisible; for a prize draw it is a real unfairness that nobody would ever notice. This tool rejects and redraws instead, so the distribution is exactly flat.
Because there are not enough different numbers in the range to fill it — ten unique values between one and five is impossible. The tool says how many are actually available rather than looping forever. Exclusions count against the total, which is how a request that looks possible can turn out not to be.
No. There is no seed, deliberately: a seeded generator is reproducible, which is the opposite of what a draw needs. If you need repeatability for testing, a seeded generator in your own code is the right tool.
No. Everything is generated in your browser and nothing is transmitted or logged, which matters if you are using this to pick a winner and need to be able to say so.
Numbers come from crypto.getRandomValues, the browser's cryptographic generator, rather than Math.random, whose output is predictable from previous values and explicitly documented as unsuitable for anything security-related. More subtle, and the thing almost every implementation gets wrong: taking a random 32-bit value modulo the range is not uniform. Unless the range divides 2^32 exactly, the lower values occur slightly more often, because the leftover portion at the top of the 32-bit space maps back onto the start of the range. For a six-sided die the bias is negligible; for a prize draw over an awkward range it is real, and it is the kind of unfairness nobody notices. So the unusable tail is rejected and redrawn — occasionally one extra draw, and every outcome exactly equally likely. Decimals use 53 bits assembled from two 32-bit draws rather than one, because a single draw provides only 32 bits of resolution and leaves visible gaps in the spread at high precision. Unique generation checks feasibility before it starts and refuses an impossible request with the count of what is actually available, rather than looping until the tab freezes — asking for ten unique numbers between one and five is the obvious case, but excluding values makes it possible to ask for something impossible without noticing. An attempt ceiling catches the near-impossible case where the range is only slightly larger than the count.