HomeTools › Random Number Generator

Random Number Generator

Made by the twittyn team · Updated August 2026

Pick one number or a whole list, in any range you like — negatives included. Turn duplicates off for raffles and lottery draws, or leave them on for independent rolls. Every number comes from your browser’s cryptographically secure generator with rejection sampling, so no value is more likely than another.

A drawn random number with its range settings
A drawn number with the range and settings that produced it.
Set a range and press Generate.

How to generate random numbers

  1. Set the range. Type the lowest and highest value you want. Both ends are included, so 1 to 6 can return a 1 or a 6. Negative numbers are fine — try −50 to 50.
  2. Choose how many numbers. One for a single pick, or up to 1,000 for a batch.
  3. Decide on duplicates. Tick No duplicates when every number must be different, like a raffle. Leave it off when each pick should be independent, like dice.
  4. Pick an order. Draw order shows the sequence exactly as it came out; ascending or descending is easier to read when you have a long list.
  5. Press Generate. The result animates in, gets added to the history below, and the Copy list button puts every number on your clipboard as a comma-separated line you can paste into a spreadsheet or a chat.

With or without duplicates

This single setting changes the mathematics of the draw, and it is the thing people get wrong most often.

Without duplicates is sampling without replacement: once a number is drawn it is removed from the pool. A raffle draw of six unique numbers from 1–49 works this way — a ball that has been pulled cannot be pulled again, so you can never get 17 twice. This is what you want when you are picking six distinct winners from a list of 200 entrants, or choosing which five of your 40 spreadsheet rows to audit.

With duplicates is sampling with replacement, where every pick starts from the full range again. Six independent dice rolls behave this way: 4, 4, 1, 6, 4, 2 is a perfectly ordinary outcome, because the die has no memory of what it just showed. Use this for anything where a repeat is meaningful rather than a mistake — simulating rolls, generating test data, or assigning one of three tasks to each of ten people.

The practical consequence: with duplicates on, drawing six numbers from 1–49 gives you a roughly 30% chance of at least one repeat. That surprises people, and it is the same counting effect behind the birthday paradox. If you asked for unique numbers, you must also have a big enough range — you cannot draw 10 unique numbers from 1–5, and the tool will tell you so instead of quietly looping forever.

How the numbers are generated

The numbers come from crypto.getRandomValues, the browser’s cryptographically secure random generator, rather than Math.random. Math.random is fast and fine for a screensaver, but its quality is not guaranteed, its internal state can sometimes be reconstructed from a handful of outputs, and different browsers implement it differently. The crypto version is the same generator used for encryption keys, and it is seeded from the operating system.

Getting raw random bits is the easy half. The harder half is turning those bits into a number in your range without skewing the odds, and that is where modulo bias creeps in.

Here is the trap in plain terms. Suppose you want a die roll from a random byte, a value from 0 to 255, and you take the remainder after dividing by 6. There are 256 possible bytes, and 256 does not divide evenly by 6: it is 42 sixes with 4 left over. Values 0, 1, 2 and 3 each have 43 bytes that map onto them, while 4 and 5 only have 42. Low numbers come up about 2.4% more often than high ones. The bias is small enough that you would never notice it by eye, and large enough to be a real flaw in a raffle you are asking people to trust.

The fix is rejection sampling, and it is simply honest: we shrink the pool to the largest multiple of the range that fits, and throw away any draw that lands outside it. For the die example we accept bytes 0–251 (that is 252, exactly 42 sixes) and discard 252, 253, 254 and 255, drawing fresh bits instead. Every accepted value now has exactly the same number of routes to it, so every face is exactly equally likely. Discarding costs a few extra draws in the worst case — and never more than one extra on average for typical ranges — which is a rounding error compared with getting the odds right. This tool applies the same logic with 32-bit words, stepping up to 53 bits of randomness for ranges too large for one word.

Unique draws use a partial Fisher–Yates shuffle rather than “draw and retry until it is new”. Both give the same distribution, but the retry approach slows to a crawl once you have drawn most of the range — picking the last number of 1–10 that way takes ten attempts on average. The shuffle picks each number in constant time, and every possible set of numbers remains equally likely.

True randomness vs pseudorandomness

To be precise about what you are getting: this is a cryptographically secure pseudorandom generator (a CSPRNG), seeded with entropy the operating system collects from physical sources — timing jitter, hardware interrupts, device noise, and on modern CPUs a dedicated hardware entropy instruction. Once seeded, it produces its output by a deterministic algorithm.

That means it is not “true” randomness in the physicist’s sense, the way atmospheric noise or radioactive decay is. What it does guarantee is that nobody can predict the next value or reconstruct the previous ones from the output, which is the property that actually matters for a fair draw. Services such as random.org sample atmospheric noise instead, and some lotteries use physical ball machines because the process must be visible and auditable, not merely unpredictable.

For a giveaway, a classroom activity, a game, or a sample of rows from a dataset, an OS-seeded CSPRNG is unpredictable in practice and unbiased in distribution. For a regulated gambling draw or an official prize with legal requirements, use whatever certified source your rules mandate — and record the draw.

What people use this for

Is anything uploaded?

No. The generator runs entirely in your browser using the built-in Web Crypto API. Your ranges, your results and your history never leave your device and are not sent to any server, and the history disappears when you close the tab. Details in our Privacy Policy.

FAQ

Can I get the same number twice in a row?

Yes, and it does not mean anything is broken. With a range of 1–10, a repeat happens one time in ten. Truly random sequences contain clusters and repeats far more often than people expect — a sequence that carefully avoided them would be the suspicious one.

Are negative numbers and zero supported?

Yes. Set the minimum to −100 and the maximum to 100 and you will get any whole number in between, including 0. Both endpoints are always included in the range.

What is the largest range I can use?

Up to about 9 quadrillion values (JavaScript’s safe integer limit, 253). Beyond that the tool refuses rather than returning numbers it cannot represent exactly. Decimals are not supported — use whole numbers and divide afterwards if you need a fraction.

Why do I get an error when asking for unique numbers?

Because the range is smaller than the number of picks. Ten unique numbers cannot exist in a range of five values. Either widen the range, ask for fewer numbers, or allow duplicates.

Can I reproduce a draw later?

No — there is no seed to re-enter, which is exactly the point for a fair draw. If you need proof of a result, screenshot it or copy the list before closing the page, and ideally record the draw while witnesses watch.

More tools: spin the spinner wheel for named entries instead of numbers, throw virtual dice with the dice roller, or browse all twittyn tools.