Ready to calculate?
Use our free Random Number Generator โ no sign-up required.
A random number generator picks numbers that follow no predictable pattern, but not all generators are equal. This guide explains how generators work, the difference between ordinary and cryptographically secure randomness, why every value should have the same chance, how unique draws and shuffles work, why repeats are normal and the basic probability behind it all. It is built around the Random Number Generator, so you can try each idea with your own range.
Key Takeaways
- A fair generator gives every value in the range the same probability, and both endpoints are included.
- Ordinary generators such as Math.random are pseudo-random and not designed to be unpredictable, while cryptographically secure ones are.
- Choose secure randomness for fair draws, and never use a web tool to create passwords or encryption keys.
- Unique draws and shuffles pick without replacement, so you cannot ask for more numbers than the range holds.
- Repeats are normal in random data, and past results never change the next draw.
Author & Formula Review
Author
Founder & Lead Developer
Reviewed by
Formula QA, source review, and calculator maintenance
Last reviewed
Math & Geometry calculator
Formulas, rounding behavior, and worked examples are checked against hand calculations and calculator QA scenarios before publishing.
Primary Sources
- MDN - Crypto.getRandomValues()
Documentation for the browser's cryptographically strong random number API.
- MDN - Math.random()
Documentation noting that Math.random is not cryptographically secure.
- NIST - random bit generation
U.S. federal standards and guidance for random number generation.
- NIST/SEMATECH e-Handbook of Statistical Methods
Reference for standard scores and statistical definitions.
Results are general-purpose estimates. Verify critical figures against official sources or a qualified professional. See our sources and methodology and editorial policy.
What a random number generator does
A random number generator picks a number from a range so that every allowed value is equally likely and the choice cannot be predicted from earlier choices. People use one to roll dice, flip a coin, choose raffle winners, assign turns, sample data and build test sets.
The settings define what values are possible: the minimum and maximum, whether the numbers are whole or decimals, which numbers to exclude and how many you want. Together they define a set of possible outcomes, and the tool picks from that set with equal probability.
- Every allowed value is equally likely
- Minimum and maximum are both included
- Settings define the set of possible outcomes
Pseudo-random versus truly random
Computers follow instructions, so software cannot produce randomness by itself. A pseudo-random number generator (PRNG) uses a formula to turn a starting value, the seed, into a long stream of numbers that pass statistical tests of randomness. Given the same seed and algorithm, it produces the same stream, which is useful for repeatable simulations.
True random numbers come from physical processes that are unpredictable, such as thermal noise or radioactive decay. Operating systems collect small amounts of such entropy and use it to seed their secure generators. In practice, a well-seeded secure generator is considered unpredictable enough for nearly all applications.
- PRNGs are formulas with an internal state
- The same seed gives the same stream
- Secure generators are seeded with system entropy
Ordinary versus cryptographically secure generators
The standard Math.random generator is quick and gives numbers that look evenly spread, but its design does not guarantee unpredictability, and its algorithm differs between browsers. It is fine for games, animations and quick sampling.
A cryptographically secure generator is designed so that an observer cannot work out the next number or recover earlier ones from the numbers they have seen. In browsers it is available as crypto.getRandomValues. Use it when fairness or secrecy matters. The tool lets you pick either source and labels each result with the source that produced it.
- Math.random: fast, not designed to resist prediction
- crypto.getRandomValues: designed to be unpredictable
- Pick Secure when fairness or secrecy matters
Fairness, modulo bias and the endpoints
A common mistake is to take a large random number and use the remainder after dividing by the size of the range. When the range does not divide evenly into the number of possible outputs, some values come up a little more often. This is modulo bias.
This tool avoids it by rejecting the few outputs that would cause the imbalance and drawing again, so each value has exactly the same probability. It also includes both the minimum and the maximum, a point that is often wrong in hand-written code. A range of 1 to 6 includes both 1 and 6, and decimals are chosen from every value on the grid, endpoints included.
- Modulo bias makes some values more likely
- Rejection sampling removes the bias
- Both endpoints are possible
Unique numbers, shuffling and repeats
When repeats are allowed, each draw is independent and the same number can come up again. When duplicates are not allowed, the tool draws without replacement, so the number of values you ask for cannot exceed the number that exist. Shuffling takes every number in the range once, in a random order, using a Fisher-Yates shuffle that gives every ordering the same chance.
Repeats are more common than intuition suggests. The table in this guide shows the chance of at least one repeat when drawing from 365 values: 23 draws already give about 50.7%. The tool displays the chance for your own settings, so a repeat does not look like a fault.
- Unique draws cannot exceed the range size
- Shuffling uses a Fisher-Yates shuffle
- Repeats are common, as the birthday problem shows
Probability basics
If a range has N equally likely values, each has a probability of 1 in N, and the expected average of many draws is the midpoint of the range. For 1 to 100, each number has a 1% chance and the average is 50.5.
Independent draws have no memory. After five heads in a row, a fair coin still has a 50% chance of heads, and thinking otherwise is the gambler's fallacy. To find the chance that something happens at least once in k tries, calculate the chance that it never happens, (1 โ p)^k, and subtract it from 1. Rolling a six at least once in four rolls has a chance of 1 โ (5/6)^4 โ 51.8%.
- Each value has probability 1 in N
- Draws have no memory
- At least once = 1 โ (1 โ p)^k
Everyday uses
Dice and coin settings (1 to 6 and 0 to 1) replace physical dice and coins. Giveaways and raffles work by numbering entries and drawing unique numbers with the secure source. Teachers and teams use shuffles to choose turn order, and testers use random numbers and decimals to build sample data.
A lottery-style pick, such as 6 unique numbers from 1 to 49 sorted in ascending order, is also easy to produce. Remember that every combination, including 1-2-3-4-5-6, has the same chance, 1 in 13,983,816, and that no tool can raise your chance of winning.
- Dice, coins and raffles
- Turn order and sampling
- Every lottery combination is equally likely
Limits, privacy and what not to use it for
This generator runs in your browser. The numbers you generate are not sent anywhere, the history is kept only in the open page, and the page link saves the settings but never the results. Because the numbers appear on a page, in history and possibly in your clipboard, do not use the tool to create passwords, encryption keys or other secrets. Use a password manager or a vetted cryptographic library for that.
The tool also cannot predict or influence games of chance, and the results are not a substitute for an audited drawing when a legal or regulatory process requires one. For important draws, record the settings, keep the evidence and follow the rules of your jurisdiction.
- Generated in your browser, not sent anywhere
- Do not use it for passwords or keys
- Use an audited process when rules require one
Quick reference: Chance of at least one repeat (the birthday problem)
Worked example: the chance that at least two of n independent random draws match when each draw has 365 equally likely values. The same formula is used by the generator to show the chance of a repeat for your own range.
| Number of draws | Chance of a repeat | Meaning |
|---|---|---|
| 10 | 11.69% | About 1 in 9 |
| 20 | 41.14% | Close to 2 in 5 |
| 23 | 50.73% | The classic birthday result |
| 30 | 70.63% | Likely |
| 40 | 89.12% | Very likely |
| 50 | 97.04% | Almost certain |
| 70 | 99.92% | Nearly certain |
Frequently Asked Questions
How do I pick a random number between 1 and 10?
Set the minimum to 1 and the maximum to 10, keep the quantity at 1 and press Generate. Both 1 and 10 can be returned.
How do I roll two dice?
Set the minimum to 1, the maximum to 6 and the quantity to 2, with duplicates allowed. Add the two numbers for the total.
How do I pick random winners without picking the same person twice?
Number the entries, set the quantity to the number of winners and turn on No duplicates. Use the Secure source for a draw people may question.
What is the chance of picking a specific number?
1 divided by the number of possible values. From 1 to 100 it is 1%, and from 1 to 6 it is about 16.7%.
Why did I get the same number twice in a row?
Independent draws can repeat. With 1 to 10, the chance that the next draw equals the last one is 10%.
Is Math.random good enough?
For games and casual sampling, yes. For fair draws that may be disputed, or any security use, choose the secure source or a dedicated cryptographic tool.
Can I get the same result again?
Not from this tool. It does not use a visible seed, so each draw is new. Copy or download the results if you need to keep them.
Does this tool work offline?
Once the page has loaded, the numbers are generated in your browser, so you do not need a connection to generate them.
Related Guides
Math & Geometry
Standard Deviation Calculator Guide
Population and sample standard deviation and variance with steps, dot plot and histogram.
Math & Geometry
Percentage Calculator Guide
Multi-mode percentage toolbox for common percent questions.
Math & Geometry
Fraction Calculator Guide
Fraction and mixed-number calculator with simplest form, decimal, percent and steps.
Math & Geometry
Z-Score Calculator Guide
Find standardized distance from the mean with percentile and probability outputs.
Math & Geometry
Volume Calculator Guide
Geometry engine for cube, frustum, ellipsoid, torus, hollow cylinder, and more with exports and share links.
Math & Geometry
Triangle Calculator Guide
Production-grade triangle solver with ambiguity handling and unit flexibility.
More calculator guides
Try the Random Number Generator
Free, instant, and accurate โ calculate now.