Maths tool · Free · No sign-up

Random Number Generator

Short answer

To pick a random number, set the lowest and highest values and press Generate: each whole number in the range is equally likely. This generator draws from the browser’s cryptographic source, crypto.getRandomValues, and rejects draws that would bias the range, so 1 to 100 really is 1 in 100 each. It can draw many without repeats.

Nothing is sent anywhere.

?Press Generate for a whole number from 1 to 100.1 number from 1 to 100
    The odds for this draw
    FactValue
    Numbers in the range100
    Chance of any one number on a draw1 in 100
    Random sourcecrypto.getRandomValues, 64 bits a draw, rejection sampling

    Whole numbers between −1015 and 1015, up to 1,000 at a time. Press Enter in any box to draw again. The numbers are made in this browser by its cryptographic random source and kept there; nothing is sent anywhere.

    Choose the range and how many numbers you want, tick No repeats for a raffle or a sample, and press Generate. The odds of the draw are shown beside it: one number, a repeat if repeats were allowed, and one exact set.

    A random number generator picks numbers so that each one in the range is equally likely and none can be predicted from the ones before. Drawing without repeats is drawing without replacement, as from a hat.

    • No sign-up
    • Nothing sent anywhere
    • Cryptographic source
    • No modulo bias

    Key facts

    Random number generator at a glance
    DetailAnswer
    RangeAny whole numbers from −1015 to 1015
    How many1 to 1,000 a draw, with or without repeats
    Random sourcecrypto.getRandomValues, the Web Cryptography API; never Math.random
    Range mappingRejection sampling on 64-bit draws, so no modulo bias
    No repeatsPartial Fisher–Yates shuffle or redraw; every set equally likely
    Where your numbers are keptThis browser only

    How to generate random numbers without repeats

    Set the range and the count, then draw.

    1. Set the range

      The lowest and highest numbers you want, such as 1 and 100.

    2. Choose how many

      From 1 to 1,000. The table shows the chance of a repeat if repeats were allowed.

    3. Tick No repeats if each number may come out once

      As for raffle tickets or choosing people.

    4. Tick Sort if you want them in order

      Useful for long lists; the draw is the same.

    5. Press Generate

      Or press Enter in any box. Draw again as often as you like.

    6. Copy the result

      The numbers copy one per line.

    Who uses a random number generator

    Anyone who needs a choice that nobody made.

    • Raffles and prize draws

      Ticket numbers without repeats, odds shown.

    • Teachers

      Picking pupils or groups fairly.

    • Researchers and surveyors

      Choosing a random sample of forms or households.

    • Games

      Turn order and numbered choices; for dice with the odds of every total, the dice roller, or the 3D dice roller to watch them tumble.

    • Event organisers

      A random running order.

    • Anyone deciding

      1 to 2 settles it, or ask the yes or no generator, or draw a card with the one card tarot.

    Modulo bias, and how this generator avoids it

    A computer’s random source gives random bits, not a number from 1 to 100. Turning bits into a range is where most generators go slightly wrong. The usual shortcut takes the random value and keeps the remainder after dividing by the size of the range. Unless the number of possible values divides evenly by the range size, some remainders come up more often than others. That unevenness is called modulo bias, and it is usually the cause of an unfair pick, not the choice between Math.random and crypto.getRandomValues, which the guide to that choice compares.

    The effect is easiest to see with a small source. One random byte has 256 equally likely values, 0 to 255. Take the remainder after dividing by 100 and the results 0 to 55 each have three ways to happen (for 0: 0, 100 and 200), while 56 to 99 have only two, because 256 = 2 × 100 + 56.

    A random byte reduced to 0–99 by its remainder
    ResultsWays out of 256ChanceCompared with fair (1 in 100)
    0 to 5531.17%17% too likely
    56 to 9920.78%22% too unlikely

    The fix is rejection sampling: find the largest multiple of the range size that fits in the source, and if a draw lands above it, throw it away and draw again. In the byte example, anything from 200 to 255 is redrawn, and every result from 0 to 99 is left with exactly two ways to happen. This generator does the same with 64-bit draws: for a range of n numbers it rejects any draw at or above 264 minus (264 mod n). With 64 bits a rejection is extremely rare, and the table under the generator counts them anyway.

    The bits come from crypto.getRandomValues. The W3C’s Web Cryptography API specification says the method “generates cryptographically strong random values”, and MDN’s reference describes Math.random, which many generators use, as “a non-cryptographic source of random numbers”. This page never calls Math.random.

    No repeats, and the odds of a set

    With “No repeats” ticked, each number can come out once, like a raffle ticket drawn from a hat and not put back. For ranges up to 100,000 numbers the generator shuffles the whole range with a partial Fisher–Yates shuffle, drawing each position with the same unbiased method; for larger ranges it draws and simply draws again on a duplicate. Both make every possible set equally likely.

    The table under the generator gives the odds of one exact set when the order does not matter, which is how lotteries are counted: the number of ways to choose k numbers from n.

    Odds of one exact set, numbers drawn without repeats
    DrawPossible setsOdds of one set
    3 from 1–101201 in 120
    6 from 1–4913,983,8161 in 13,983,816
    5 from 1–6911,238,5131 in 11,238,513
    6 from 1–5945,057,4741 in 45,057,474

    These are the odds of matching a set chosen in advance, for the draw alone; a real lottery may add a bonus ball or other rules, which change its published odds.

    How likely is a repeat? The birthday problem

    When repeats are allowed, a repeat comes sooner than most people expect. In a room of 23 people the chance that two share a birthday is just over a half, even though there are 365 possible birthdays. The same arithmetic applies to any draw with repeats: the chance of no repeat is (1 − 1/n) × (1 − 2/n) × … for each number after the first, and the chance of at least one repeat is 1 minus that.

    Chance of at least one repeat when repeats are allowed
    DrawChance of a repeat
    3 rolls of a die (1–6)44.44%
    4 numbers from 1–1049.6%
    10 numbers from 1–10037.18%
    13 numbers from 1–10055.72%
    23 birthdays (1–365)50.73%
    38 numbers from 1–1,00050.93%
    50 birthdays (1–365)97.04%

    The generator shows this figure for any draw of more than one number, so you can see whether “repeats allowed” is likely to give you a repeat before you press Generate. If a repeat would spoil the draw, such as picking raffle winners or pupils, tick No repeats.

    Settings for fair draws: raffles, classrooms and samples

    A fair draw is only fair if everyone agrees how it was made. Set the range to match what you are choosing from, decide on repeats before you press Generate, and keep the result: the numbers stay on the page and can be copied.

    Settings for common draws
    DrawFromToHow manyNo repeats
    A raffle with 250 tickets, 3 prizes12503Yes
    Pick 5 pupils from a register of 281285Yes
    Roll two dice162No
    Toss a coin 10 times (0 tails, 1 heads)0110No
    A random sample of 40 from 1,200 forms1120040Yes
    Shuffle a running order of 12 acts11212Yes

    Random samples are the serious use. Choosing which survey forms or households to follow up by a draw, rather than by hand, keeps the sample from leaning towards the convenient ones; the guide to how many people to survey covers how large the sample should be. For random words rather than numbers there is the random word generator, which uses the same unbiased method. To toss a coin with the sides named, 1 to 100 coins at once and the odds of every streak, use the coin flip, or to call a side first and score the guess, guess heads or tails; to roll dice, the dice roller; to pick names rather than numbers, the random picker.

    What this generator does not do

    This generator draws whole numbers for games, raffles, classrooms and samples. It does not make passwords or encryption keys: the W3C specification itself says “do not generate keys using the getRandomValues method” and points to its key-generation method instead, and a password is better made by a password manager. It does not draw decimals, weighted numbers or numbers outside −1015 to 1015, and it keeps no record of past draws beyond the last one in this browser.

    What this generator does and does not do
    It doesIt does not
    Whole numbers from a cryptographic source, with no modulo biasUse Math.random
    1 to 1,000 numbers, with or without repeats, sorted if you likeDraw decimals or weighted numbers
    Show the odds of a number, a repeat and a setMake passwords or encryption keys
    Keep the last draw in this browserSend the numbers anywhere

    This generator or a typical random number generator

    What this page adds to a typical random number generator.

    This random number generator compared with a typical one
     This generatorA typical generator
    Random sourcecrypto.getRandomValues, namedUsually Math.random, unnamed
    Range mappingRejection sampling, no modulo biasRemainder or rounding, not stated
    No repeatsFisher–Yates or redraw, every set equally likelyOften available
    Odds shownOne number, a repeat, an exact setNo
    Range−1015 to 1015, exactOften up to 253 or less
    Your numbers leave the browserNeverVaries

    More random tools

    Every random tool on the site runs in your browser, needs no sign-up, and sends nothing anywhere.

    All 6 random tools, by category: Coins & yes or no (2) · Dice (2) · Cards & draws (1) · Numbers & picks (1)

    Frequently asked questions

    How do I generate random numbers without repeats?

    Set the range and how many numbers you want, tick No repeats and press Generate. Each number can then come out only once, as when tickets are drawn from a hat. You cannot ask for more numbers than the range holds: 11 different numbers from 1 to 10 is impossible, and the generator says so.

    Is this random number generator truly random?

    It uses the browser’s cryptographic random source, crypto.getRandomValues, which the W3C specification requires to give cryptographically strong random values. That is unpredictable for any practical purpose, though it is not a physical device such as dice or a radioactive source.

    What is modulo bias?

    The unevenness that comes from turning random bits into a range by taking a remainder. A byte has 256 values; taking the remainder after dividing by 100 makes 0 to 55 come up 3 times in 256 and 56 to 99 only twice. This generator avoids it by redrawing any value above the largest multiple of the range size.

    How do I pick a random number between 1 and 100?

    Leave the range at 1 to 100 and the count at 1, and press Generate. Every whole number from 1 to 100, both ends included, has the same 1 in 100 chance on each draw. Press Generate again for another, or Enter in any box.

    Can I use this for a raffle or lottery numbers?

    Yes. Number the tickets from 1, set the range to the number of tickets, the count to the number of prizes, and tick No repeats. For lottery-style numbers, such as 6 from 1 to 49, the table gives the odds of one exact set, 1 in 13,983,816.

    Why did I get the same number twice?

    Because repeats were allowed, and repeats are more common than they feel. Drawing 10 numbers from 1 to 100 with repeats gives at least one repeat 37% of the time; 23 birthdays share one about 51% of the time. Tick No repeats if a repeat would spoil the draw.

    Does the generator include the minimum and maximum?

    Yes. Both ends are included, so 1 to 6 works as a die and 0 to 1 as a coin. The table shows how many numbers are in the range: 6 for 1 to 6, 101 for 0 to 100.

    Can I generate negative or very large random numbers?

    Yes, any whole numbers from minus one quadrillion to one quadrillion (1015). The generator works in exact 64-bit draws, so large ranges stay unbiased and every number is written out in full. A range that wide makes a repeat very unlikely, and the table shows how unlikely.

    Open the random number generator

    Free, no sign-up, and what you enter stays in your own browser.