Skip to main content
ponderloop

Random Number Generator

Set a range and press Generate: the page picks a whole number between the two ends, both included, and every number in the range is exactly as likely (1 in 100 for 1 to 100). It can also draw several numbers at once with or without repeats, sort them, flip coins and roll dice. Each draw uses your browser’s cryptographic random number generator with rejection sampling, so there is no modulo bias, and nothing is sent anywhere.

Updated Runs in your browser: nothing you enter is uploadedHow this tool works

Random numbers

Quick picks:

Example result, printed in the page (not random)

42

    1 number from 1 to 100. Chance of this exact result: 1 in 100.

    Flip a coin

    Not flipped yet

      Heads or tails, 50/50.

      Roll dice

      Not rolled yet

        Two six-sided dice.

        Drawn on your device with your browser’s Web Crypto random number generator, without modulo bias. Nothing you draw is sent or saved.

        The chance of one exact result

        Every result of a fair draw is equally likely; this is the chance of any single one. For several different numbers, order is ignored.
        DrawChance
        A coin flip1 in 2
        One six-sided die1 in 6
        A number from 1 to 101 in 10
        A number from 1 to 1001 in 100
        A number from 1 to 1,0001 in 1,000
        3 different numbers from 1 to 101 in 120
        5 different numbers from 1 to 501 in 2,118,760
        6 different numbers from 1 to 491 in 13,983,816

        Two dice: the chance of each total

        Each die is fair, but totals are not: there are six ways to make 7 and only one to make 2 or 12.
        TotalWaysChance
        21 of 362.8%
        32 of 365.6%
        43 of 368.3%
        54 of 3611.1%
        65 of 3613.9%
        76 of 3616.7%
        85 of 3613.9%
        94 of 3611.1%
        103 of 368.3%
        112 of 365.6%
        121 of 362.8%

        Why plain “% n” is unfair, and how often a draw is redone

        A random 32-bit word has 4,294,967,296 values. Unless n divides that exactly, “word % n” gives the smallest few results one extra chance. Rejection sampling throws those leftover words away and draws again.
        Range size nLeftover wordsChance a draw is redoneBias without rejection
        20nevernone: 2 divides 2^32 exactly
        641 in 1,073,741,8244 of the 6 results more likely by 1 part in 715,827,882
        1061 in 715,827,8836 of the 10 results more likely by 1 part in 429,496,729
        100961 in 44,739,24396 of the 100 results more likely by 1 part in 42,949,672
        1,0002961 in 14,510,025296 of the 1,000 results more likely by 1 part in 4,294,967
        1,000,000967,2961 in 4,440967,296 of the 1,000,000 results more likely by 1 part in 4,294
        3,000,000,0001,294,967,29630.2%1,294,967,296 of the 3,000,000,000 results twice as likely as the rest

        How to pick a random number

        1. Set the range. Type the lowest and highest numbers you want, for example 1 and 100. Both ends can come up. Negative numbers work too.
        2. Choose how many. Leave it at 1 for a single number, or ask for several. Turn on “Allow repeats” if the same number may come up twice, like rolling a die again.
        3. Generate. Press Generate. Each press is a new, independent draw; earlier results have no effect on the next one.
        4. Share the settings, not the result. Copy link to these settings sends the range and options. Whoever opens it draws their own number: a link cannot prove what someone else drew.

        Frequently asked questions

        Is this random number generator really random?
        It uses crypto.getRandomValues, the random number generator browsers provide for encryption keys, seeded by your operating system. That is unpredictable in practice, far stronger than the Math.random function most quick tools use. Each number in your range has exactly the same chance, and one draw tells you nothing about the next.
        What is modulo bias, and why does it matter?
        A computer produces random bits, not random numbers from 1 to 100. The shortcut is to take a big random number and keep the remainder after dividing by the size of the range, but unless the range divides the number of possible values exactly, the smallest results get slightly more chances. This page throws those leftover values away and draws again (rejection sampling), so the bias is exactly zero. The table above shows how rarely that redraw is needed.
        How do I pick several numbers without repeats, like lottery numbers?
        Set the range (1 to 49, say), set How many numbers to 6, leave Allow repeats off and tick Sort smallest first. The numbers are drawn with Floyd’s algorithm, which gives every set of 6 the same chance, 1 in 13,983,816 for 6 from 49. This is for fun and games: it cannot make any lottery ticket more likely to win.
        Why can I share the settings but not the result?
        Because a link cannot prove a draw. A link that said “the number was 17” could be typed by anyone, so it would show nothing about what was really drawn. The fair way to settle something is to agree on the settings, then draw once where everyone can see it, for example on a shared screen. The settings link makes that easy; every page that opens it draws its own fresh number.
        Is every number between the two ends possible?
        Yes. Both ends are included, so a range from 1 to 10 has ten possible results, each with a 1 in 10 chance. Ranges can be as wide as minus to plus one quadrillion (10^15).
        Are the coin flip and dice fair?
        Yes. A coin is a draw from two outcomes and a die a draw from 1 to its number of sides, with the same unbiased method as the numbers. Rolling several dice rolls each one separately, which is why a total of 7 with two dice is far more common than 2 or 12.
        Is anything I draw saved or sent?
        No. The numbers are drawn and shown on your device only. The page keeps no history, and analytics (only if you accepted them) record that a button was pressed, never a number or a setting.

        How it works

        Every draw starts from crypto.getRandomValues, which fills 32-bit words with random bits from the operating system’s secure generator. To get a whole number from 0 to n − 1, the page takes one word (two for ranges over 2^32, combined into a 53-bit value) and accepts it only if it is below the largest multiple of n that fits; otherwise it draws again. The accepted word modulo n is then exactly uniform, and adding the low end of your range gives the result. Numbers without repeats use Floyd’s sampling algorithm (one draw per number, however large the range) and are then put in random order with a Fisher–Yates shuffle, unless you asked for them sorted. Coins are a draw from two outcomes and dice from 1 to the number of sides. Nothing is precomputed, stored or sent: each press is a fresh draw on your device.

        Sources

        All toolsHome & DIY calculators