How the Random Number Generator works

Numbers are drawn from your browser's cryptographically secure random generator (crypto.getRandomValues). A common mistake is to take a random value and use the remainder after dividing by the size of the range, which makes low numbers slightly more likely. This tool uses rejection sampling instead: it draws just enough random bits to cover the range and draws again whenever the value falls outside it, so every number from the minimum to the maximum, both included, has exactly the same chance.

The minimum and maximum can be any whole numbers from -9,007,199,254,740,991 to 9,007,199,254,740,991, the largest integers JavaScript can store exactly. With No duplicates, each value appears at most once: for large ranges the tool keeps drawing and skips repeats, and for small ranges it shuffles the possible values, so it stays fast even when you ask for every number in the range. If you ask for more unique numbers than the range contains, it tells you instead of looping forever. With Include decimals, it picks from every value with that many decimal places, for example 0.00, 0.01 … 1.00, and prints them exactly without floating-point rounding.

How to use the Random Number Generator

  1. Enter the minimum and maximum. Both are included in the results and can be negative.
  2. Enter how many numbers you need (1 to 10,000). Tick No duplicates if each number may appear only once.
  3. Tick Include decimals and set the decimal places if you need numbers such as 3.75.
  4. Choose the sort order and separator, then select Generate numbers or press Ctrl + Enter (Cmd + Enter on a Mac).
  5. Copy the numbers or download them as a .txt file.

Example

Minimum 1, maximum 49, How many 6, No duplicates, Smallest first, separated by commas:

4, 11, 23, 30, 38, 47

Minimum -1, maximum 1, How many 4, Include decimals with 3 decimal places:

0.482
-0.917
1.000
-0.036

Minimum 1, maximum 5 and How many 6 with No duplicates gives the message The range contains only 5 possible values, so 6 unique numbers cannot be picked. Widen the range, lower How many, or allow duplicates.

Common use cases

  • Drawing winners for a raffle or giveaway without picking the same entry twice.
  • Rolling dice or picking lottery-style numbers, such as 6 unique numbers from 1 to 49.
  • Creating random test values, sample sizes or IDs for spreadsheets and test scripts.
  • Choosing a random sample of rows, pages or questions by their numbers.

Common errors and how to fix them

The minimum must not be greater than the maximum
Swap the two values, or check for a stray minus sign in one of them.
Range bounds must be safe integers
The range goes beyond the largest integer JavaScript can represent exactly, about 9 quadrillion. Numbers past that point cannot be generated without silently losing precision, so the tool stops instead.
The same number came up more than once
Independent random draws repeat; that is what makes them random. If you need values that never repeat, generate more than you need and remove duplicates, or use the UUID Generator for guaranteed-unique identifiers.

Frequently asked questions

Are the numbers truly random and fair?

They come from crypto.getRandomValues, the browser's cryptographically secure random generator. The tool uses rejection sampling rather than the remainder of a division, so every number in the range has exactly the same chance.

How large can the range be?

The minimum and maximum can be any whole numbers from -9,007,199,254,740,991 to 9,007,199,254,740,991, the largest integers JavaScript represents exactly. With decimals the limit is smaller, because the numbers are drawn in steps of the smallest decimal place.

What happens if I ask for more unique numbers than the range has?

The tool shows a message saying how many possible values the range contains, instead of generating a list with repeats. Widen the range, ask for fewer numbers or allow duplicates.

How do decimals work?

With 2 decimal places, every value from the minimum to the maximum in steps of 0.01 is equally likely, including both ends. Numbers are printed with exactly that many decimal places, for example 5.00 and 12.30.

Can I use it for dice rolls?

Yes. Set the minimum to 1, the maximum to 6 and How many to the number of dice, and leave No duplicates unticked.