Article
by Textool Team
Updated: November 2026
Read time:
12 min
INSTANT TOOL SOLUTION
Need a number right now? Try the Random Number Generator — pick a range, set how many numbers you need, and get an instant result. For a quick pick, use the Random Number Between 1 and 10 tool.
A random number generator, often shortened to RNG, produces a value from a set range, where each value can be selected. The user usually sets the range first, then asks for one number or several at once.
Random numbers remove human choice from a selection — a teacher, a developer needing test data, and a game all need a result not picked by hand. For a classroom pick or a game, a result that looks scattered is usually enough; for a password or an encryption key, it is not, because an attacker who guesses the next value can take over an account.
Try a small range with the Random Number Between 1 and 10 tool. Each click is a fresh draw. Previous displayed results are not excluded from subsequent selections.
A computer is a predictable machine: given the same input and the same instructions, it gives the same output. So computers generate random numbers in one of two ways — they follow a fixed recipe that produces numbers that look random, or they measure something outside the computer that is hard to predict. Most everyday generators use the first way, and are called pseudorandom number generators, or PRNGs.
A pseudorandom number generator, or PRNG, is a deterministic algorithm: the same starting point and the same steps always give the same result. NIST defines it in similar terms: a deterministic algorithm that takes a short, truly random input, called a seed, and produces a much longer sequence that appears to be random. The numbers look random because the recipe spreads them out, and a person who does not know the starting value cannot easily work out what comes next. Not every PRNG is hard to predict: how predictable one is depends on its algorithm, seed, and how much of its internal state an attacker can learn or guess. A CSPRNG adds security properties on top of pseudorandomness, so its output stays unpredictable even to someone who knows the algorithm and has seen earlier outputs, provided its seed and internal state stay protected.
That recipe is fast, needs no special hardware, and can produce as many numbers as needed.
A common example is Math.random() in JavaScript. MDN describes it as a pseudorandom number from 0 up to, but not including, 1, and states directly that it is not cryptographically secure and should not be used for anything related to security.
A seed is the starting value for a PRNG. The algorithm takes the seed, produces the first output, then uses its internal state to produce the next, and so on — the whole sequence is fixed once the seed is fixed. Imagine a generator producing numbers from 1 to 100 — a hypothetical example, not a run from any real tool. With the same seed, the whole list repeats in the same order; change the seed, and the sequence changes.
That reproducibility helps a developer testing a program, who wants the same sequence again. It is a weakness for a password or a token: if an attacker can guess or learn the seed, they can run the same algorithm and produce the same sequence, including the secret value.
Textool’s tools do not show a seed control, and this guide makes no claim about which algorithm Textool uses, because that implementation has not been verified.
Entropy, in this context, means unpredictable input, gathered from physical sources — variations in electronic noise, radioactive decay, or atmospheric noise — and from non-physical sources, such as the exact timing of a key press or mouse movement. Those human-interaction timings can contribute entropy, but a single keystroke or mouse movement does not automatically supply enough security-grade entropy on its own; the amount depends on how unpredictable they actually are. See NIST’s entropy-source guidance (SP 800-90B).
A true random number generator, or TRNG, uses such a physical source, so its output cannot be reproduced by running the same calculation again — its strength, and its limitation, since physical sources can be slow and need special hardware. In practice, many systems mix the two ideas, gathering entropy to seed a secure generator; modern cryptographic systems commonly use a CSPRNG seeded with sufficient entropy, rather than direct physical output for every value.
The right choice depends on the risk if someone guesses the result: a classroom pick carries low risk, so a PRNG is reasonable, while a guessed encryption key can give an attacker access. A result that looks random is not automatically safe, and a physical source is not automatically useful for every purpose.
Many people expect a random generator to avoid repeats, as if it were dealing cards from a deck. Most generators do not work that way: each draw is a fresh selection from the full range, and a value that has already appeared can appear again. That is not a fault; it is what independent draws mean.
An independent draw is one whose result does not depend on any earlier draw. A coin toss is an independent event: the coin does not remember that it landed on heads last time. A number drawn from 1 to 10 is the same — assuming independent draws with each value equally likely, the chance that the next number is 7 is 1 in 10, whether 7 appeared in the last draw or not. Drawing cards without putting them back is sampling without replacement — each card can appear only once. Generating random numbers with a tool is usually sampling with replacement: each number is put back, in effect, before the next draw.
Suppose, as a hypothetical example, a generator produces 4, 7, 4, 9, 2 from 1 to 10. The value 4 appears twice, but that does not mean the generator is broken: the chance that the next number is 4 is still 1 in 10, under the same assumption.
A real, observed example shows the same point: on 5 November 2026, a live check of the Random Number Between Range tool, set to 1 to 2 with a quantity of 5, gave 2, 1, 2, 1, 2 — with only two possible values and five draws, a repeat was unavoidable, and that run confirmed the tool has no no-repeat setting. The general Random Number Generator tool gave a similar result, 1 to 3 with a quantity of 5 producing 2, 2, 2, 2, 1.
Repeats become more likely as more numbers are drawn, even from a large range. With 12 draws from 1 to 100, the chance that at least two numbers match is about 50%. With 20 draws, it rises to about 87%. Both assume independent draws with each value equally likely — about 49.7% and about 87.0% before rounding. This is the same idea behind the birthday paradox, where only 23 people are needed for about a 50% chance that two share a birthday (about 50.7% before rounding, on the same assumptions across 365 days).
Random results do not always look evenly spread: a short sequence can contain a run of the same value, or a gap where a value never appears. Imagine a hypothetical sequence of 20 numbers drawn from 1 to 10: 3, 3, 8, 9, 9, 9, 2, 5, 1, 8, 8, 4, 6, 3, 7, 9, 2, 2, 5, 8. The value 9 appears four times, 8 appears four times, and 10 never appears at all. Randomness does not mean that each value appears equally often in a short run; over a very long run, the counts tend to even out.
A run of three 9s does not mean that 9 is hot. Assuming independent draws with each value equally likely, the chance of three 9s in a row, before the draws start, is 1 in 1,000, but any exact sequence of three numbers from 1 to 10 has the same chance.
The gambler’s fallacy is the mistaken belief that past results change the chance of a future result in an independent process. It is also called the Monte Carlo fallacy, after a night in 1913 when a roulette wheel at Monte Carlo landed on black 26 times in a row.
It feels like fairness: after five heads in a row, tails feels due — but the coin has no memory, and the chance of heads on the next toss is still 1 in 2. For a fair coin, with independent tosses, the chance of five heads in a row, before the tosses start, is 1 in 32. The same applies to random numbers: if a generator has just produced 7 three times in a row, the chance that the next number is 7 is still 1 in 10 for a range of 1 to 10. A number does not become less likely after appearing several times, and it does not become more likely either.
The law of large numbers is often confused with the gambler’s fallacy, but it says something different: over a very large number of draws, the proportion of each value tends to settle close to its expected share. It does not say that a short run will be corrected by the next few draws, or that a missing value is due.
Randomness and unpredictability are related, but they are not the same thing. Randomness, in the statistical sense, means a sequence has no obvious pattern and each value appears with about the expected frequency over a long run. Approximately equal frequencies alone do not establish statistical randomness: other patterns and relationships between values also matter, such as whether one value tends to follow another. Unpredictability means no one can work out the next value in advance, even if they know how the generator works and have seen earlier values. A sequence can be statistically random and still be predictable, if it was made by a PRNG with a known seed.
Ask two questions: does the output look scattered, and could someone who knows the method and has seen earlier outputs work out the next one? If both answers are yes, the generator is random-looking but not secure.
A cryptographically secure pseudorandom number generator, or CSPRNG, is a PRNG designed to a higher standard. It is designed to make prediction computationally infeasible under its security assumptions, provided the seed and internal state are appropriately protected — even for someone who knows the algorithm and has seen earlier outputs. NIST defines a cryptographic generator in those terms — its output is unpredictable if the seed is not known — and OWASP draws the same line: ordinary PRNGs must not be used for anything security-critical.
A CSPRNG is necessary when the value must not be guessed — passwords, password reset tokens, session identifiers, and encryption keys — where an ordinary PRNG is not a safe substitute, even if it looks random. MDN makes the same point for JavaScript: use the Web Crypto API, specifically Crypto.getRandomValues(), instead of Math.random(). Other languages have their own secure random functions, as listed by OWASP.
A random number generator is a process or a tool that produces a value from a set range, where each value can be selected — a physical process, such as measuring atmospheric noise, or an algorithm, such as a PRNG that starts from a seed.
A PRNG uses a fixed algorithm and a seed, so the same seed gives the same sequence. A true random number generator, or TRNG, uses a physical process, such as electronic noise, so its output cannot be reproduced by running the same calculation again.
Random numbers repeat because most generators make independent draws, each taken from the full range again, so a value that has already appeared can appear again.
No. For independent draws, the chance of a particular value stays the same on every draw, whatever happened before — a number that has appeared several times is not due to disappear, and one that has not appeared is not due to appear.
No, not safely: an ordinary PRNG can look random and still be predictable if its seed or algorithm is known. For passwords, tokens, and encryption keys, use a cryptographically secure generator, such as the Web Crypto API’s Crypto.getRandomValues() in a browser.
Article
by Textool Team