Random Number Generator
Generate secure random numbers in any range, one or many at a time, each ready to copy.
Formula used
Secure integer in the inclusive range [min, max]:
range = max − min + 1
raw = crypto.getRandomValues(Uint32Array) (32-bit unsigned)
reject raw values ≥ floor(2³² / range) × range (removes modulo bias)
result = min + (raw mod range)
Related calculators
Worked example
Range: min = 1, max = 6, count: 5
range = 6 − 1 + 1 = 6. Each draw takes a secure 32-bit value, rejects the biased tail, then maps it into 1–6.
Example output: 4, 1, 6, 3, 3 — each with its own copy button.
A random number generator sounds like a toy until you notice how often a fair, unbiased draw is exactly what a task needs. Games are the obvious case — rolling for initiative, drawing a raffle ticket, picking a starting player, or settling a dispute with a coin flip that neither side can dispute. Research and quality control use randomness more seriously: picking a representative sample from a long list, selecting test subjects without bias, or choosing which items in a batch to inspect so the selection does not favor the easy ones. Software work leans on randomness for generating tokens, salts, and one-time codes where predictability would be a security hole. Even casual uses benefit from it — a random restaurant pick when no one can decide, a random playlist order, or a random writing prompt to break a creative block. The value in every case is the same: the outcome is not influenced by whoever is holding the tool, so it settles arguments, removes selection bias, and keeps automated systems from being guessable. This generator exists to make that fair draw a single click rather than a coin, a hat, or a questionable spreadsheet formula.
Getting useful output starts with setting the bounds and the quantity deliberately. The minimum and maximum are both inclusive, so a range of 1 to 6 returns any whole number from 1 through 6, exactly like a die, and a range of 0 to 1 is not what you want if you meant 1 to 100. Match the range to the thing you are modeling: a 52-card deck wants 1 to 52, a percentile roll wants 1 to 100, a month wants 1 to 12. The count is how many independent draws you want in one go, and it is worth thinking about whether you want one draw or many before you press generate, because requesting twenty numbers at once is far more convenient than pressing the button twenty times. If you are sampling from a list, set the range to the list length and treat the output as row indices. If you are dividing a range into bands — say assigning people to one of four groups — pick a range that is a clean multiple of the number of groups, or simply draw and then bucket the result. A little thought about range and count up front turns a generic stream of digits into answers that map directly onto the problem you brought.
This generator draws from the browser's cryptographic random source rather than the ordinary pseudo-random function, and the distinction is worth understanding. A normal random function is designed to be fast and reproducible enough for simulations and games where the outcome only needs to feel random; it can be predicted if someone knows its internal state, which is fine for a bouncing animation and dangerous for anything that gates access or value. The cryptographic source here is built to resist prediction, which is why it is the right choice for tokens, passwords, salts, draw winners, and any situation where someone might try to guess the next value. For a board-game dice roll the extra strength is harmless; for a giveaway where a small prize is on the line it is the difference between a draw no one can contest and one a determined person could game. The trade-off is only that cryptographic generation is slightly heavier than the trivial alternative, a cost that is invisible at the small counts this tool produces. The practical guidance is simple: use a secure source whenever the numbers are public, valuable, or security-related, and this generator already does that by default, so you get the safer behavior without having to ask for it.
The most misunderstood part of generating several numbers at once is that each draw is independent, so repeats are not a bug — they are exactly what rolling the same die several times would give you. If you need a set of distinct values, such as five unique lottery numbers or a sample with no duplicates, this tool will not guarantee that on its own, because it samples with replacement. The fix is to either draw from a range large enough that repeats are unlikely, or to do the de-duplication yourself by re-drawing any repeat, or to use a purpose-built sampler if your task truly requires a draw without replacement. The other expectation to set is about distribution: over a small number of draws the results can look uneven — three sixes in a row is perfectly possible and not a sign the generator is broken — while over many draws the counts even out. If you are using the output to assign people to groups or to sample, resist the urge to "fix" a run that looks unbalanced; true randomness is lumpy in the short run by definition. Knowing these two behaviors — independent repeats and short-run clumpiness — keeps you from misreading a correct result as a faulty one. It is also worth remembering that the generator produces numbers, not meanings — a draw of 17 only matters because you decided in advance what 17 represents, whether a row in a list, a minute of the hour, or a door to pick. Settling that mapping before you generate, rather than after, is what keeps the output fair and useful instead of a number you then quietly nudge to fit a preferred outcome. Randomness is a tool for removing your own bias, and it only works if you commit to the result before you see it.
Frequently asked questions
How is this different from a normal random function?
It uses crypto.getRandomValues(), the browser's cryptographically strong random source, rather than Math.random(). The output is far less predictable, which matters for draws, tokens, passwords, and anything where guessability is a concern.
Are the minimum and maximum included in the range?
Yes. Both bounds are inclusive, so a range of 1 to 6 can return any whole number from 1 through 6, just like rolling a die.
Does it avoid bias toward certain numbers?
Yes. It uses rejection sampling — discarding the rare raw values that would skew the result — so every number in your range is equally likely, with no modulo bias toward the lower values.
Can numbers repeat when I generate several at once?
Yes. Each number is drawn independently, so repeats are possible and expected, exactly like rolling the same die multiple times. This is not a draw-without-replacement lottery picker.
Is the generation private?
Yes. Everything runs in your browser. No numbers, ranges, or results are sent anywhere.