toolqik

13 · Random Values

Random Number Generator

Random numbers in any range: integers or decimals, unique or not.

Runs in your browser
Decimal places
Options
Numbers

    About this tool

    Pick a winner, roll dice, sample rows for a test, assign people to groups or seed a game: this random number generator gives you numbers between any minimum and maximum, as whole numbers or with up to four decimal places. Turn on No duplicates for lottery-style draws where each number appears once.

    Every value comes from crypto.getRandomValues(), your browser’s cryptographically secure random number generator, never Math.random(), and nothing is sent to a server.

    How to use it

    1. Enter the minimum and maximum. Both are included, so 1 to 6 can return 1 and 6.
    2. Choose how many numbers you need, and the number of decimal places.
    3. Turn on No duplicates for a draw without repeats, or Sort ascending to order the results. Press G for a new set.

    Is it really random and fair?

    Yes. A common mistake is random % range, which makes some numbers slightly more likely than others when the range doesn’t divide evenly (modulo bias). This generator discards those uneven values and tries again (rejection sampling), so every number in the range has exactly the same chance. Decimals are generated as whole numbers of hundredths (or thousandths) and then divided, so 0.10 and 0.99 are just as likely as each other.

    Ideas

    • Raffles and giveaways: number your entries, set the range to 1–N and turn on No duplicates for multiple winners.
    • Dice: 1–6 for a d6, 1–20 for a d20; set How many to the number of dice.
    • Random sampling: pick row numbers to spot-check in a spreadsheet or database.
    • Test data: prices with 2 decimals, ages from 18 to 80, quantities from 1 to 10.

    Random numbers in code

    // Unbiased random integer in [min, max] (crypto-secure)
    function randomInt(min, max) {
      const span = max - min + 1;
      const limit = Math.floor(2 ** 32 / span) * span; // reject the uneven tail
      const buf = new Uint32Array(1);
      do crypto.getRandomValues(buf); while (buf[0] >= limit);
      return min + (buf[0] % span);
    }
    randomInt(1, 6);   // a fair die roll

    FAQ

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

    Leave the minimum at 1 and the maximum at 100 and click Generate. Both 1 and 100 can come up.

    Can I get random numbers without repeats?

    Yes. Turn on “No duplicates”. You can draw up to as many numbers as the range contains; 1–49 allows up to 49 unique numbers.

    Can it generate decimals?

    Yes, with 1 to 4 decimal places. Each decimal value in the range is equally likely.

    Is this suitable for a prize draw?

    The numbers are cryptographically secure and unbiased. For draws with legal requirements, record the settings and results, or run the draw in front of witnesses.

    Can I use negative numbers?

    Yes. Any range works, such as −50 to 50, up to about 9 quadrillion (2^53).

    esc
    ↑↓ navigate↵ open