Skip to content
ToolBoxGeniehome

Random Number Generator

Developer Tools · Added

Pick one number or ten thousand, between any two bounds, with or without repeats. Every value comes from your browser cryptographic random number generator rather than from the usual arithmetic pseudo-random function, and whole numbers are drawn by rejection sampling so that every value in the range is genuinely equally likely.

Up to 10,000 at once.

100 whole numbers in this range, both ends included.

How to use the random number generator

  1. 1Set the lowest and highest value. Both ends are included in the range.
  2. 2Say how many numbers you want — anything from one to ten thousand.
  3. 3Tick No repeats if every number in the draw must be different.
  4. 4Choose whole numbers or up to four decimal places, and whether to sort the output.
  5. 5Press Generate, then copy the result or download it as a text file.

Examples

A single pick

Input
1 to 100, one number
Result
A single value, both ends possible

The range is inclusive, so 1 and 100 are each as likely as anything between them.

A draw with no repeats

Input
1 to 50, six numbers, no repeats
Result
Six different values, sorted if you ask for it

Asking for more numbers than the range holds is refused with an explanation rather than looping forever.

Decimals for test data

Input
0 to 1, 500 numbers, 4 decimal places
Result
500 values between 0.0000 and 1.0000

Decimal draws cannot be unique — the point of them is a continuous spread, and duplicates at four places are vanishingly rare anyway.

About the random number generator

Where the randomness comes from

There are two families of random number generator and they are good at different things. A pseudo-random generator starts from a seed and applies arithmetic to produce a sequence — fast, repeatable, and perfectly adequate for shuffling a playlist or jittering an animation. Knowing the seed and the algorithm gives you every number it will ever produce, which is a feature when you want a reproducible simulation and a disaster when you want a secret.

A cryptographically secure generator is seeded from physical unpredictability the operating system collects — timing jitter, interrupt patterns, dedicated hardware where it exists — and is built so that seeing part of the output tells you nothing about the rest. Browsers expose it as crypto.getRandomValues, and it is what this page calls. It is marginally slower and there is no practical reason to prefer the alternative for the sort of draws people come to a page like this for.

One consequence worth stating plainly: because the source is unpredictable, a draw cannot be repeated. There is no seed to write down and no way to reconstruct an earlier result. If reproducibility matters more than unpredictability — regenerating the same test dataset, for example — a seeded generator in your own code is the right tool and this one is the wrong one.

Drawing without repeats

Sampling without replacement is a different algorithm from sampling with it, and the naive approach fails in a way that is easy to miss. Drawing at random and discarding duplicates works well while the sample is a small fraction of the range, and degrades badly as it approaches it: pulling the last of a hundred values out of a hundred takes a hundred attempts on average, and the total cost grows without a fixed bound.

The fix is to switch method once the sample gets large relative to the range. Past halfway, this tool builds the whole range, shuffles it with Fisher-Yates — where each swap index comes from the same unbiased source — and takes as many as you asked for. That is linear in the size of the range rather than unbounded, and it makes drawing 90 numbers from 100 as quick as drawing 10.

Fisher-Yates is worth knowing about in its own right, because the obvious alternative is subtly wrong. Sorting a list by a random comparison function does not produce a uniform permutation; it produces a distribution skewed by the sort algorithm, and the skew depends on which sort your runtime happens to use. It is one of the most widely repeated shuffling bugs there is, and the correct algorithm is three lines long.

Frequently asked questions

What makes these numbers better than a spreadsheet RAND?
The source. A spreadsheet or a plain script uses a pseudo-random generator seeded from something predictable, and its output is a deterministic sequence that merely looks random. This uses crypto.getRandomValues, which draws from the operating system entropy pool — the same source used to generate keys. For a raffle, a shuffle or anything where somebody has an incentive to predict the result, that difference is the whole point.
What is modulo bias and why does it matter?
It is the skew you get from squeezing a 32-bit number into a smaller range with a remainder. If the range does not divide evenly into 2^32, the low values of the range get one extra chance each and come up slightly more often. In a hundred draws you would never see it; over a hundred thousand it is measurable. This tool avoids it by discarding any draw that falls in the uneven tail and drawing again, which costs on average under two attempts and removes the skew entirely.
Can I use this to pick a lottery or prize winner?
You can generate the numbers, but understand what the tool does and does not give you. It produces an unbiased draw and it keeps no record of it — nothing is stored, nothing is sent anywhere, and reloading the page cannot recover a previous result. That is good for privacy and useless as evidence. If a draw needs to be defensible to the people who lost it, run it on a recorded call or use a process built to be audited, because this page cannot testify that any particular number came out of it.
Why can I not get unique decimal numbers?
Because uniqueness over a continuous range is a different problem from uniqueness over a set of integers, and the guarantee would be close to meaningless. Between 0 and 1 at four decimal places there are only 10,001 distinct values, so the constraint would behave like a small integer draw wearing a disguise; over a wider range, collisions are so unlikely that enforcing the rule would achieve nothing. If you need distinct decimals, draw unique integers and divide.