Random Number Generator
Generate cryptographically random integers within any range. Pick how many, with or without duplicates.
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
- Set the minimum and maximum of your range — both ends are included.
- Choose how many numbers to generate, from one up to 1,000.
- Toggle "No duplicates" on for a unique set (like lottery numbers) or off for independent draws.
- Click Generate to produce the numbers.
- 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?
What is modulo bias and does this tool have it?
Are both the min and max included?
What does the "No duplicates" toggle do?
Can I generate more unique numbers than the range allows?
Can I rely on this for a contest draw?
Why prefer a secure generator over a simple one?
What about long runs of similar numbers?
Related tools
More tools you might find useful in the same flow.
Name Picker
Random name picker — paste a list of names and draw a winner at random, perfect for raffles, giveaways, and team picks. Free, instant, no signup needed.
Random Color
Generate random colors with copyable HEX, RGB, and HSL values. Constrain to pastel, vibrant, or grayscale, or roll a whole random RGB color palette.
List Randomizer
List randomizer — shuffle any list of items into a random order with one click, great for queues, brackets, and playlists. Free, instant, no signup needed.
PIN Generator
PIN generator — create random 4, 6, or 8 digit PIN numbers (or any length) with real cryptographic randomness, one at a time or in bulk. Free and instant.
Built by Muhammad Tahir · About