Apex Conversion

Random Number Generator

Need a number between 1 and 100? Drawing raffle winners who can't win twice? Pick any range, choose how many numbers, and generate them with cryptographic randomness — with or without repeats.

Numbers come from crypto.getRandomValues — your operating system's entropy pool — rather than Math.random(), whose internal state can be reconstructed from a handful of outputs. Rejection sampling removes modulo bias, so every value in the range is exactly equally likely. Runs entirely in your browser.

How Fair Random Numbers Are Made

This tool draws 32-bit values from crypto.getRandomValues and maps them onto your range with rejection sampling: any draw that would skew the distribution is discarded and redrawn, so a range of 1–100 gives every number exactly a 1% chance. When repeats are off, it runs a partial Fisher–Yates shuffle over the whole range (for ranges up to 100,000), the same algorithm that shuffles a deck of cards without ever dealing one twice — so picking 6 unique numbers from 1–49 works exactly like a lottery draw.

Quick recipes

Coin flip            min 0, max 1
Die roll             min 1, max 6
Percent chance       min 1, max 100
Lottery-style draw   pick 6 of 1–49, repeats off
Random PIN digits    pick 4 of 0–9, repeats on
Raffle winners       pick N of ticket range, repeats off

Math.random()         fast, but predictable & not for security
crypto.getRandomValues OS entropy pool, unpredictable

Frequently Asked Questions

Is this random number generator truly random?

It uses crypto.getRandomValues — a cryptographically secure generator seeded from your operating system's entropy pool (hardware timing, interrupts) — so outputs are unpredictable and uniform. That's a different class from Math.random(), whose internal state can be reconstructed from a few observed outputs. Only dedicated hardware measuring quantum or atmospheric noise is 'more' random, and for picking numbers the difference is unmeasurable.

How do I generate random numbers with no repeats?

Turn off 'Allow repeats' — the tool then runs a partial Fisher–Yates shuffle over the whole range, the same algorithm that shuffles a deck without dealing a card twice. The only constraint is that the range must contain at least as many numbers as you're picking: you can't draw 10 unique numbers from 1–5.

Can I use this for a raffle or prize draw?

Yes — number the tickets, set min to 1 and max to the ticket count, set how many winners, and turn repeats off so nobody wins twice. Because every value is drawn with rejection sampling, each ticket has exactly equal probability — for 500 tickets, precisely 1-in-500 each. Generate once in front of witnesses rather than re-rolling until you like the result.

What is modulo bias and why does it matter?

Mapping a random 32-bit value onto a range with a plain remainder (x % n) over-selects smaller numbers whenever 2³² isn't evenly divisible by n — for a 1–100 range, the first 96 values get a few extra chances each. Rejection sampling fixes it by discarding the handful of draws above the largest exact multiple of n and redrawing, making every outcome exactly equally likely.

Related Tools