Random Number Generator

Choose integers or decimals, allow repeats or not, and pick the randomness source. The sum and average of the draw are shown with the result.

How this generator picks its numbers

By default the tool draws from your browser's crypto.getRandomValues, the Web Crypto source that is backed by the operating system's cryptographic random generator. For integer ranges it takes only as many random bits as the range needs and throws away any value that lands outside the range (rejection sampling), which keeps every number exactly equally likely. "Draw without duplicates" uses a partial Fisher-Yates shuffle. If you untick the cryptographic option, the tool switches to JavaScript's ordinary Math.random(). Both modes are offered on purpose: for raffles and games you will not notice any difference, but it is worth knowing where the difference matters. This page is meant for draws, simulations and everyday choices. Passwords, API tokens and keys should come from a dedicated generator such as the Password Generator or the UUID Generator, never from numbers displayed in a browser tab.

Pseudorandom versus cryptographic randomness

Most "random" numbers in software are pseudorandom: a formula repeatedly updates a small internal state, so the sequence looks random but is fully determined by that state. If someone learns the state, every later value can be predicted.Math.random() is designed for speed and good statistical behaviour, and the language specification does not promise unpredictability. Each engine picks its own algorithm; V8, used by Chrome and Edge, has used a 128-bit xorshift128+ generator.crypto.getRandomValues is specified to draw on the operating system's cryptographically secure generator, built so that seeing earlier outputs gives no practical way to compute later ones.

Math.random()crypto.getRandomValues
NaturePseudorandom, tuned for statistics and speedCryptographically secure source
PredictabilityInternal state can be inferred from enough outputDesigned to be unpredictable
Seeding / replayNot possible (the browser seeds it)Not possible
Suitable forGames, simulations, casual drawsTokens, keys, passwords, draws where fairness matters

Neither mode on this page can be seeded, so you cannot replay a result. If you need reproducible numbers for an experiment or a test fixture, use a seedable pseudorandom library in your own code. For a prize draw the opposite holds: the inability to replay or pre-compute the outcome is a feature.

Modulo bias: why "random % range" is subtly unfair

A common shortcut turns a 32-bit random value (0 to 4,294,967,295, so 232 possibilities) into a range of size N with value % N. Unless 232 is a multiple of N, the remainder r = 232 mod N means that the first r outcomes each correspond to one extra raw value, so small results turn up slightly more often than large ones. For a die (N = 6), 232 = 6 × 715,827,882 + 4, so results 1 to 4 appear 715,827,883 / 715,827,882 times as often as 5 and 6, an excess of about 1.4 in a billion. Harmless in practice, but it grows quickly with the range.

Range size N232 mod N (r)Share of outcomes favouredTheir excess probabilityError bound of the 53-bit float method (N / 253)
6466.67%+1.4e-7%6.7e-16
453168.89%+1.0e-6%5.0e-15
1009696.00%+2.3e-6%1.1e-14
1,00029629.60%+2.3e-5%1.1e-13
1,000,000967,29696.73%+0.023288%1.1e-10
1,000,000,000294,967,29629.50%+25.00%1.1e-7

At a range of one billion, about 29.50% of the outcomes are favoured, each by 25.00%, which is a real distortion. This tool avoids it: for N = 100 it draws 7 random bits (0 to 127) and discards anything of 100 or more, retrying until the value fits. The chance of discarding is always below 50%, so the average is under two attempts, and all N values come out with exactly equal probability. The Math.random() mode computes Math.floor(Math.random() * N); because that generator yields 53-bit fractions, the unfairness is bounded by about N / 253 (last column), negligible for any range up to 232. For wider ranges the tool refuses Math.random mode and switches to the cryptographic one automatically.

Integer ranges and decimal ranges

Integer mode includes both ends: with a minimum of 1 and a maximum of 6 the range size is 6, and each value has probability 1/6. The size is always (maximum − minimum + 1), and negative ranges such as −10 to 10 work the same way. A classic bug is writing Math.floor(Math.random() * (max - min)) + min, which can never return max.

Decimal mode multiplies a uniform value in [0, 1) by (maximum − minimum), adds the minimum and rounds to the chosen number of decimal places. Because of rounding the maximum can show up, and with few decimal places repeated values are common. For example, drawing from 0 to 1 with one decimal place has eleven possible results from 0.0 to 1.0, but the two ends only cover half a rounding interval, so each appears half as often as the others. If every candidate must be equally likely, draw an integer from 0 to 10 and divide by 10 yourself. "No duplicates" does not apply in decimal mode.

Repeats allowed or not

With repeats allowed (sampling with replacement), every draw starts from the same situation, so the same number can legitimately come up twice. As you draw more numbers, a repeat becomes the expected outcome rather than a sign of trouble.

Range size NNumbers drawn kProbability of at least one repeat
45629.4%
1001037.2%
3652350.7%
1,0005071.2%
1,000,0001,00039.3%

Draw ten numbers from 1 to 100 with repeats allowed and the chance that some pair matches is 37.2%. The famous birthday problem is the same calculation: with 23 people and 365 days the chance of a shared birthday is 50.7%. So "it repeated, therefore it is broken" is almost always wrong. When duplicates would be a problem, such as winning numbers or seat assignments, tick "no duplicates".

Drawing without replacement works from a list of every value in the range: step i swaps position i with a uniformly chosen position from i to the end, and after k steps the first k entries are your result. Every ordered selection of k distinct values is equally likely. For ranges larger than a million the tool does not build the list; it remembers the values already drawn and redraws on a clash, which is fine because it never draws more than 1,000 numbers.

Worked examples

Example 1: six numbers from 1 to 45 without repeats. The number of unordered sets is C(45, 6) = 8,145,060, so each set has probability 1/8,145,060. If order matters, multiply by 6! = 720 to get 5,864,443,200 ordered outcomes. The set 1, 2, 3, 4, 5, 6 is exactly as likely as 7, 13, 21, 30, 38, 44; nothing makes a tidy-looking set rarer. For a dedicated number picker see the Lottery Number Generator.

Example 2: six numbers from 1 to 45 with repeats. There are 456 = 8,303,765,625 ordered outcomes, so the chance of reproducing a particular sequence is 1.20e-10. The chance that at least two of the six match is 29.38% (first row of the repeat table).

Example 3: three numbers from 10 to 19 without repeats. The range size is 19 − 10 + 1 = 10, giving 10 × 9 × 8 = 720 ordered results. The three numbers must always differ, and their sum must lie between 10 + 11 + 12 = 33 and 17 + 18 + 19 = 54. A displayed sum outside that band would signal a problem.

Common mistakes and myths

When not to use this tool

Official prize draws and anything regulated usually need witnesses, logs or a third party to establish fairness, and this page provides none of that. It is not intended for gambling. Do not use displayed numbers as passwords, one-time codes or encryption keys. The numbers are generated in your browser's memory and are not sent or stored by this page, and because there is no seed, a result cannot be regenerated later. Copy the output if you need a record.

Putting the result to use

For a raffle, enter the first and last ticket numbers as the range, tick "no duplicates" and draw as many winners as you have prizes. To split a group into teams use the Random Team Generator, to assign outcomes one by one try the Ladder Game (Amidakuji), and for small repeated experiments such as dice or coins the Coin Flip & Dice Roller is quicker. In simulations, raise the count and compare the sum and average with the expected values: the mean of a uniform integer from 1 to 100 is 50.5, and large samples should land close to it.

Frequently Asked Questions

When should I tick "no duplicates"?

Use it whenever the same number must not appear twice, such as raffle winners, seat numbers or lottery picks. If you ask for more numbers than the range contains, for instance 11 numbers from 1 to 10, the tool shows an error because it is impossible.

Are these numbers truly random?

They are generated by algorithms and operating-system entropy rather than a physical dice roll. The default cryptographic source is designed to be unpredictable and is more than adequate for draws and games. With the option unticked the tool uses Math.random, which is statistically fine but not designed to resist prediction, so do not rely on it for anything security-related.

I got the same number twice in a row. Is something wrong?

No. With a small range repeats are common: on a 1 to 6 range the chance of the same value twice in a row is 1/6, about 16.7%.

Can I set a seed to get the same sequence again?

No. Neither source can be seeded by the page. For reproducible tests and experiments use a seedable pseudorandom library in your own code.

Can decimal mode return the maximum value?

Yes. The raw value is below the maximum, but rounding to your chosen decimals can display exactly the maximum. When you need strict include or exclude rules, use integer mode.

How many numbers can I draw at once?

Up to 1,000 per click, within integer ranges smaller than 253 so that every value is represented exactly.

Related tools