Skip to content
Processing locally — files never leave your device

Random Number Generator

Generate cryptographically random integers within any range. Pick how many, with or without duplicates.

Bloggers — embed this widget for free

Add this tool to your own site with one line of HTML. Free forever — just keep the small credit link.

How to use Random Number

  1. Set the minimum and maximum of your range — both ends are included.
  2. Choose how many numbers to generate, from one up to 1,000.
  3. Toggle "No duplicates" on for a unique set (like lottery numbers) or off for independent draws.
  4. Click Generate to produce the numbers.
  5. Copy the comma-separated results with one click.

Random number generator: an even, unbiased integer in any range

Set a minimum and maximum, say how many numbers you want, and choose whether they must be distinct — this tool returns integers spread perfectly evenly across the range. It spans the casual (a quick 1–100, a random array index, an odd-sided die like a d7) and the careful (lottery picks, raffle ticket draws, sampling without replacement), and the whole computation happens in your browser. The thing it does better than a one-line snippet is keep the distribution genuinely flat, which is the focus below.

Mapping into your range without bias

The interesting part of a range generator is not the source of entropy — this page uses the browser's secure generator, which past outputs never give away — but how a raw value gets squeezed into your minimum-to-maximum window. The naive approach, taking the value modulo the range size, is subtly broken whenever the range does not divide the source evenly: the lowest few values come up slightly more often. Over a single roll you would never notice; over thousands of draws the tilt is real and, in a draw with stakes, unfair.

Rejection sampling: the fix for modulo bias

To keep every value exactly equally likely, this tool uses rejection sampling. It carves the source into whole blocks the size of your range and discards any value that lands in the small leftover band at the top, drawing again instead. Worked example: to pick 1–6 from a byte (0–255), 256 is not a multiple of 6, so the four extra values 252–255 are thrown away; only 0–251 are used, and those split cleanly into six equal groups. The cost is the occasional re-draw; the payoff is a genuinely flat distribution.

Unique draws versus independent draws

The duplicates toggle changes the underlying model:

  • No duplicates (sampling without replacement): every number in the result is distinct, like drawing numbered balls and not returning them. Ideal for lottery numbers or choosing distinct items.
  • Duplicates allowed (independent draws): each number is generated on its own, so repeats are possible — the model for rolling the same die many times.

If you request more unique numbers than the range can hold, there is simply no valid answer, so the tool produces nothing rather than looping forever.

A note on probability and streaks

Even with perfect randomness, results look clumpy, not tidy. Numbers repeat, gaps appear, and short runs cluster — that is what genuine randomness looks like. A related curiosity is the birthday problem: among just 23 people, there is already a better-than-even chance two share a birthday, because the number of possible pairs grows fast. The same effect means that drawing many numbers from a small range will collide far sooner than intuition suggests, which is exactly why the "no duplicates" option exists.

Common uses

Lottery and raffle picks, assigning random IDs, sampling rows from a dataset, rolling non-standard dice (a d7 is just a 1–7 range), seeding games, choosing a random winner, or generating test data. Anywhere you need fair integers in a known range, this is the general-purpose tool.

Related tools

  • Dice Roller — when your range is a standard die and you want modifiers and multiple dice handled for you.
  • PIN Generator — for fixed-length numeric PINs with leading zeros preserved.
  • Name Picker — draw winners by name rather than by ticket number.
  • Coin Flip — the trivial 1-or-2 case of a range draw.

Frequently asked questions

How are the numbers kept evenly distributed?
Each draw stretches a large secure random integer down into your range using rejection sampling, which discards the small leftover band that would otherwise tilt the odds. The result is a flat distribution: no lean toward the low or high end.
What is modulo bias and does this tool have it?
Modulo bias is the skew you get when you fold a raw random value into a range with the % operator and the range does not divide evenly into the source. This tool avoids it by rejecting the unevenly-covered tail rather than using a plain modulo, so every value stays equally likely.
Are both the min and max included?
Yes, the range is inclusive at both ends. A 1 to 6 range can return 1, 2, 3, 4, 5, or 6, each with the same probability — there is no off-by-one at either edge.
What does the "No duplicates" toggle do?
On gives a distinct set, like drawing numbered balls without putting them back — right for lottery picks or unique IDs. Off makes each number an independent draw, so the same value can appear more than once.
Can I generate more unique numbers than the range allows?
No — there is no valid answer to "10 unique values from 1 to 5", so the tool returns nothing instead of looping forever. Widen the range or switch duplicates on.
Can I rely on this for a contest draw?
Yes. Number your entrants and draw their numbers here. If the outcome must be provable, record it on screen so the draw can be reviewed afterwards.
Why prefer a secure generator over a simple one?
A simple seeded formula can sometimes be reconstructed from its outputs; the secure source this tool uses cannot, so a number that decides who wins something holds up to scrutiny.
What about long runs of similar numbers?
Clusters and gaps are expected — true randomness is lumpy, not evenly spaced. A repeated value in a "duplicates allowed" run is chance, not a fault.

More tools you might find useful in the same flow.

Built by Muhammad Tahir · About