Random Number Generator
Draw numbers, roll dice or flip coins with every number in the range, every die face and both coin sides equally likely. That holds with values left out, with decimals, which are shown exactly, and in a draw without repeats even between 1 and 1018.
Random generator
Recent results
Nothing yet. Press the main button and your results collect here until you reload the page.
About the randomness
Values come from the secure random generator built into your browser
(crypto.getRandomValues), never from Math.random. Settings are kept in
this browser only and nothing is uploaded.
Runs on your device. Nothing you type or record is uploaded. Keeps working without a connection while the page is open. Works with touch. Saves your settings on this device; the Recent results list is cleared when you reload the page.
Added
How to use the random number generator
- Choose a mode with the tabs: Numbers, Dice or Coin.
- In Numbers, enter the smallest and largest value and how many numbers you want (1 to 10,000). Untick Allow repeats if every number must be different. Switch the type to Decimals to choose 1 to 6 decimal places.
- Optionally sort the list, type values to leave out in the exclude field (separated by commas or spaces) and pick how the copied text is separated: commas, spaces or new lines.
- In Dice, tap a preset such as d6 or d20, or type a notation like 2d6 (1 to 100 dice, 2 to 1000 sides). In Coin, enter the number of flips (1 to 10,000).
- Press the main button, or press Enter in any field. Use Copy result to put the result on the clipboard. Earlier results stay in the Recent results list until you reload the page. If you change a setting, the result box says it is outdated until you press the button again.
How it works
Every value comes from crypto.getRandomValues, the secure random generator built
into your browser and seeded from operating-system entropy. The page never uses
Math.random. Strictly speaking this is a cryptographically secure
pseudo-random generator: its output cannot be predicted from earlier output.
No modulo bias. The raw output is a 32-bit integer. Turning it into a choice among n options with “value mod n” is slightly unfair, because 232 is rarely a multiple of n. For a six-sided die, 232 = 6 × 715,827,882 + 4, so the last four raw values would make the faces 1 to 4 a little more likely. The tool uses rejection sampling: it throws away any raw value at or above the largest multiple of n that fits (here 4,294,967,292) and draws again. For ranges wider than 32 bits it joins several 32-bit words, keeps the bits the range needs and redraws when the number falls outside it.
Repeats allowed. Each number is an independent draw, so every value in the range has the same chance every time.
Repeats not allowed. The tool runs a partial Fisher–Yates shuffle: for each of the k places it swaps a randomly chosen remaining value into position. Instead of building a list of the whole range, it remembers only the positions that moved, so 10 different numbers between 1 and 1018 cost memory for about 10 entries, not for 1018. The List Randomizer explains why a Fisher–Yates shuffle gives every order the same chance.
Exclusions. The draw is made among the values that remain, and the index is then shifted past each excluded value, so every remaining value is equally likely.
Decimals. With p decimal places the range is a grid of steps of 10−p, and every grid value, both ends included, has the same chance. Values are handled as big integers scaled by 10p, so floating-point noise such as 0.30000000000000004 cannot appear. If your limits have more decimals than allowed, the minimum is rounded up and the maximum down to the grid; the line under the fields shows the range actually used.
Dice and coins. Each die is an independent draw from 1 to the number of sides, and the sum is shown. A d10 here shows 1 to 10 and a d100 shows 1 to 100, unlike a printed ten-sided die that runs from 0 to 9. A coin flip uses a single random bit, so heads and tails are equally likely.
Examples
Example 1: a lottery-style pick. Minimum 1, maximum 49, how many 6, repeats off, sort ascending. The line under the fields reads “49 possible values from 1 to 49”. Each press gives six different numbers in order, for instance 4, 11, 19, 23, 38, 45. There are 49!/(6! × 43!) = 13,983,816 possible sets, and each is equally likely.
Example 2: leaving numbers out. Range 1 to 10 and the exclude field set to
3 5. The line reads “8 possible values from 1 to 10 (2 excluded)”. Ask
for 9 different numbers and the result box says: “You asked for 9 different numbers, but
only 8 are available. Lower the count, widen the range or allow repeats.”
Example 3: decimals. Type Decimals, 3 places, minimum 0, maximum 1. The line reads “1,001 possible values from 0.000 to 1.000”. Every result shows exactly three decimals, trailing zeros kept, for example 0.407 or 0.250.
Example 4: two dice. On the Dice tab, 2d6 shows “2d6 · sum can be 2 to 12” above the dice. Of the 36 equally likely pairs, six add up to 7 (1 in 6, about 16.7%), while only one adds up to 2 (about 2.8%).
Repeats, streaks and other things that look suspicious
- Repeats are normal. Draw 5 numbers from 1–100 with repeats allowed and the chance of at least one duplicate is 1 − (100 × 99 × 98 × 97 × 96) / 1005, about 9.7%. This is the same effect as the birthday problem, where 23 people are enough for a better-than-even chance of a shared birthday.
- Streaks are normal. Of the 1,024 possible 10-flip sequences, 846 (about 83%) contain three or more identical results in a row, and 476 (about 46%) contain four or more. Exactly 5 heads happens in only 252 of them, about 24.6%.
- Past results do not matter. After five heads the next flip is still 50/50; thinking otherwise is the gambler’s fallacy.
Using random numbers in class and at home
Teachers can number the students 1 to N and draw unique numbers to pick presenters or choose a sample. Probability lessons work well with real data: roll 2d6 a hundred times or flip 1,000 coins, then compare the counts with the theory.
Do not use it where a rule prescribes a specific method, such as an official lottery, and do not use it to create passwords or keys. The Password Generator is built for that.
Frequently asked questions
Are the numbers truly random?
They come from a cryptographically secure generator seeded by the operating system, so they are unpredictable in practice. Technically it is a pseudo-random generator, not a physical noise source, and there is no seed to type, so a sequence cannot be repeated on purpose.
How many numbers can I generate at once?
Up to 10,000 per press. With repeats off you cannot ask for more numbers than the range holds after exclusions, and the tool tells you how many are available.
Can I use it for a raffle or giveaway?
Statistically, yes: every entry number has the same chance. Rules for prize draws differ by place, so check them first.
Why does a d10 show 1 to 10 instead of 0 to 9?
This tool follows the common tabletop convention in which a ten-sided die gives 1 to 10 and a percentile roll gives 1 to 100. If you need 0 to 9, set the minimum to 0 and the maximum to 9 on the Numbers tab.