Random Number Generator

Generate one or many random integers or decimals within a range, with or without repeats.

Quick answer. A random number generator picks values at random between a lower and upper limit. With the default range of 1 to 100, every whole number has a 1% chance. Drawing 10 numbers with repeats allowed gives a 37% chance that at least one repeats.

How random is this?

The generator uses your browser’s built-in pseudo-random number generator, Math.random(). It produces numbers that are statistically indistinguishable from true randomness for everyday purposes: picking a raffle winner, rolling for a game, choosing a sample or shuffling a list. It is not suitable for cryptography or security, such as passwords or keys. For those, use the Password Generator, which uses the browser’s cryptographically secure source.

The options

  • Lower and upper limit: both ends are included. The default is 1 to 100.
  • How many numbers: from 1 to 10,000 at a time.
  • Integer or decimal: integers are whole numbers spread evenly across the range; decimals are rounded to 0 to 20 digits of precision, such as 42.37.
  • Allow duplicates: turn it off for results that must all be different, like drawing numbers from a hat.
  • Sort result: none, ascending or descending.

Worked example with the default numbers

With a lower limit of 1 and an upper limit of 100, the generator returns a whole number from 1 to 100 and each number has the same 1% chance. Across many draws the average settles near (1 + 100) ÷ 2 = 50.5, and the typical spread (standard deviation) of a single draw is about 28.9. Seeing the same number twice in a row has a 1% chance on any given pair of draws, so it happens now and then and is no sign that the generator is broken.

10,000 simulated draws from 1 to 100, counted in tens (fixed-seed illustration)Each ten should get about 1,000. Ours range from 908 to 1,061, which is normal chance variation, and the average is 50.0 against an expected 50.5.10,000 simulated draws from 1 to 100, counted in tens (fixed-seed illustration)1-1099011-201,05721-3099331-401,01641-501,06151-6098861-701,00571-8090881-9099691-100986
Draws spread evenly across the range, with small random differences between groups.

Drawing without repeats

Ask for 10 numbers with repeats turned off and you get 10 different values, as if drawn from a hat without putting them back. The generator builds the list of all possible values, shuffles it fairly and takes the first ones, so there are 17,310,309,456,440 possible sets of 10 numbers from 1 to 100 (order ignored), all equally likely. You cannot ask for more unique numbers than the range holds: 50 unique integers from 1 to 20 is impossible, and the page tells you so. For huge ranges with few picks, the generator draws and rejects repeats instead.

PickFromPossible sets
52015,504
5502,118,760
510075,287,520
1010017,310,309,456,440

Why repeats happen more than you expect

When repeats are allowed, duplicates appear sooner than most people guess. This is the birthday paradox. The chance of at least one repeat among k draws from 100 values is 1 − (100 × 99 × … ÷ 100k):

Chance of at least one repeat when drawing from 1 to 100 with repeats allowedWith 10 draws the chance of a repeat is already 37%, and at 20 draws it is 87%. This is the birthday paradox.Chance of at least one repeat when drawing from 1 to 100 with repeats allowed5 numbers9.7%10 numbers37.2%12 numbers49.7%15 numbers66.9%20 numbers87.0%30 numbers99.2%
If every result must be different, turn off duplicates instead of hoping for luck.
Numbers drawnChance of a repeat
59.7%
1037.2%
1249.7%
1566.9%
2087.0%
3099.2%

Decimals

In decimal mode the number is picked uniformly between the limits and rounded to the precision you choose. With a precision of 2, the range 0 to 1 has 101 possible values. If you turn duplicates off, any exact repeat is re-drawn, which matters only at very low precision.

Sorting and reading long lists

When you generate many numbers, use the sort option to see them in order, which makes it easier to spot gaps or to read off the smallest and largest values. Large results are shown on one line separated by commas, so you can copy them straight into a spreadsheet and split them by comma. Numbers of a thousand or more are displayed with thousands separators.

Fair draws and common uses

  • Raffles and classroom picks: give each person a number and generate within that range, without repeats for several winners.
  • Games: simulate dice or a spinner by setting the limits to the faces.
  • Sampling: pick random rows or IDs from a list.
  • Test data: generate decimals to simulate measurements.

Common mistakes

  • Using this for passwords, keys or anything security-related.
  • Assuming a number is “due” after a streak. Each click is independent.
  • Forgetting that both limits are included.
  • Allowing duplicates in a draw that needs unique winners.

How to read your result

The large box shows one number, or a list for several. If you asked for sorted output, it is in order. Refreshing or clicking Generate again produces a fresh set; nothing is saved between runs. For analysis of the numbers you generated, use the Mean, Median, Mode, Range Calculator or the Standard Deviation Calculator.

This generator is not suitable for cryptography or for regulated gambling and lotteries, which require certified sources.

What to do next

Common questions

Why would I disallow duplicates?

Whenever each result must be unique: assigning raffle numbers, shuffling a deck, or picking several different winners from a pool without repeats.

Does refreshing give a different result?

Yes. Every time you click Generate, a fresh set of random numbers is produced. Nothing is cached or remembered between runs.

Is this truly random?

It uses your browser's pseudo-random generator, which is statistically fair for everyday uses. It is not suitable for cryptography; use the Password Generator for secure random values.

Are the lower and upper limits included?

Yes. With limits 1 and 100, both 1 and 100 can appear.

Why did I get the same number twice?

Each draw is independent, so repeats are normal when duplicates are allowed. The chance of a repeat among 10 draws from 1 to 100 is about 37%.

How many numbers can I generate at once?

Up to 10,000. Without repeats, you cannot ask for more unique integers than the range contains.

Sources: MDN: Math.random(); NIST: Random Bit Generation

More Math Calculators

Pick another tool to jump straight to it.