Random Number Generator

About this calculator

The Random Number Generator picks a number between your lower and upper limits each time you press the button. The simple version returns one whole number. The comprehensive version lets you generate many integers or decimals at once, choose whether duplicates are allowed, set the decimal precision and sort the list.

1 to 10,000
digits after the decimal point

Embed this calculator

Paste this code into a Custom HTML block on your site. The calculator fits the width of the block. Adjust the height in the code if you want more room for results.

Find this widget in the publisher directory

How the generator works

Each press of the Generate button draws fresh random values from your browser's cryptographically strong random source, then scales them into the range you chose. Every integer in the range has the same probability of being picked, and both limits are included. Nothing is sent to a server, so your numbers stay on your device and are different every time.

Simple version

Enter a lower limit and an upper limit and press the button. You get one random integer from the lower limit to the upper limit, inclusive. With limits of 1 and 100, every number from 1 to 100 has a 1 in 100 chance.

Comprehensive version

Switch to the comprehensive version for more control:

  • How many numbers: generate from 1 to 10,000 values at once.
  • Type of result: integers, or decimals with a precision of your choice.
  • Allow duplicates: choose Yes for independent draws, like rolling a die repeatedly, or No for unique values, like drawing numbers from a hat without putting them back.
  • Sort the results: leave the list in the order generated, or sort ascending or descending.

When duplicates are not allowed, you cannot ask for more numbers than the range contains. Asking for 20 different integers between 1 and 10 is impossible, and the generator tells you so.

Random versus pseudo-random

True randomness comes from physical processes such as atmospheric noise or radioactive decay. Most software uses pseudo-random algorithms, which follow a deterministic formula that starts from a seed. This tool uses the web cryptography interface, which mixes in entropy collected by your operating system, so the output is unpredictable for practical purposes and suitable for games, drawings, sampling and picking winners.

Common uses

TaskSettings
Roll a six-sided die1 to 6, simple
Pick a lottery style set1 to 49, 6 numbers, no duplicates, ascending
Choose a raffle winner1 to the number of tickets, simple
Random sample of rows1 to the row count, no duplicates
Test data with centsDecimal, precision 2, duplicates allowed

Worked example

Suppose you want five different numbers from 1 to 50 for a classroom draw, listed in order. Switch to comprehensive, set the limits to 1 and 50, ask for 5 numbers, choose integer, set duplicates to No and sort ascending. A typical result might be 4, 17, 23, 38, 49, but it will be different each time. The chance of any particular set of five is 1 in 2,118,760, the number of ways to choose 5 items from 50.

Fair use and limits

Because every outcome is equally likely, random streaks happen. Getting the same number twice in a row is not a sign that the generator is broken. For regulated lotteries and security keys, use a certified draw or a dedicated key generator rather than a website.

Tips

For a coin flip use limits of 0 and 1. For a random percentage use 1 to 100. To shuffle a list of n items, generate the numbers 1 to n with duplicates off and read them as a new order. To choose a random date, generate a day number and a month number separately. Decimals are handy for simulating measurements, prices or probabilities, where a precision of 4 or more gives a smooth spread between 0 and 1. If you need the same list again later, copy it, because every press produces a new one.

Frequently needed ranges

A standard die uses 1 to 6, two dice use 2 to 12 but are not uniformly distributed, a deck of cards has 52 positions, a roulette wheel has 0 to 36, and a birthday draw uses 1 to 365. Percentages, ages, ticket numbers and page numbers all map to simple ranges. If your range starts at zero, just enter 0 as the lower limit, and negative limits work too, for example -50 to 50 for a temperature or a score swing.

Frequently asked questions

Are the limits included?
Yes. For integers, both the lower and upper limit can be returned.
Can I generate decimals?
Yes. Use the comprehensive version, choose Decimal and set the number of digits after the decimal point.
How do I get numbers with no repeats?
In the comprehensive version set Allow duplicates to No. The count cannot exceed the number of possible values in the range.
Is this truly random?
It uses your browser’s cryptographic random source, which is unpredictable enough for games, draws and sampling.

Formulas and sample results on this page were checked against independent references. Page last reviewed or updated . How we verify calculators. Project led by Shaun Connell.