# Random Number Generator

> Free random number generator: draw random numbers in any range, with or without duplicates, sorted or unsorted, using cryptographic randomness.

Draw random numbers between any minimum and maximum. Control how many you draw, allow or forbid duplicates, and sort the results, all with real cryptographic randomness.

*Interactive tool: enter your values at https://toollantern.win/random-number-generator/ and results update instantly in your browser.*

## What this tool does

The generator draws whole numbers between a minimum and maximum you set. You choose how many to draw, whether repeats are allowed, and whether the results come out sorted or in draw order. Up to 1,000 numbers per draw.

## How the randomness works

Draws come from **crypto.getRandomValues**, the browser's cryptographic random generator, not the weaker Math.random. To map random bits onto your range without bias, the tool uses **rejection sampling**: it draws a 32-bit value and retries if it falls in the small leftover zone that would make some numbers slightly more likely (modulo bias). Every number in your range ends up exactly equally likely.

## Worked example

Drawing **5 numbers between 1 and 49** without duplicates and sorted could give **4, 17, 23, 31, 45**. That is the same shape as a lottery draw, and each of the 1,906,884 possible combinations is equally likely.

## Duplicates on or off

With duplicates off, the tool draws from a shrinking pool, like pulling names from a hat: each result is unique. With duplicates on, every draw is independent, like rolling a die again. If you ask for more unique numbers than the range holds, the count is capped at the range size.

## Limitations

Random is not the same as fair for every purpose: for regulated lotteries or gambling, use a certified system. For games, raffles, sampling and everyday decisions, this generator's randomness is more than sufficient.

## Frequently asked questions
### How do I generate a random number between 1 and 100?

Set the minimum to 1, the maximum to 100, how many to 1, and press Generate. That is also the default setup when the page loads.

### Are the numbers truly random?

They come from crypto.getRandomValues, your browser's cryptographic random generator, with rejection sampling to remove modulo bias. Each number in the range is exactly equally likely.

### What does allow duplicates do?

On, every draw is independent and repeats can appear, like rolling dice. Off, each number can appear at most once per draw, like pulling names from a hat.

### Can I draw lottery numbers?

Yes. Set the range to 1-49 (or your lottery's range), the count to how many balls are drawn, turn duplicates off, and turn sorting on. Each combination is equally likely.

### Why is there a 1,000 number limit?

To keep the page fast and readable. For larger samples, draw in batches.

---
Interactive version: https://toollantern.win/random-number-generator/
