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.
How to use the random number generator
- 1Set the lowest and highest value. Both ends are included in the range.
- 2Say how many numbers you want — anything from one to ten thousand.
- 3Tick No repeats if every number in the draw must be different.
- 4Choose whole numbers or up to four decimal places, and whether to sort the output.
- 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?
What is modulo bias and why does it matter?
Can I use this to pick a lottery or prize winner?
Why can I not get unique decimal numbers?
Related tools
Password Generator
Developer Tools
Generate a strong random password with your own length and character rules, and see its real entropy.
UUID Generator
Developer Tools
Generate cryptographically random UUIDs in bulk, with formatting options.
Average Calculator
Calculators
Find the mean, median, mode and range of a list of numbers, pasted in any format.