home / Math / random number calculator

Random Number Generator

The Random Number Generator is a free online tool that produces random integers or decimals within any range you choose, with or without repeats. It uses your browser's cryptographically secure generator, runs entirely on your device, and needs no sign-up.

Modify the values and click the Calculate button to use.

Related: Standard Deviation Calculator | Password Generator Calculator

How This Generator Works

This tool draws numbers from your browser's crypto.getRandomValues, a cryptographically secure pseudo-random number generator (CSPRNG) seeded by the operating system's entropy pool. Nothing is sent to a server — the numbers are produced on your own device and are never transmitted or stored.

The generator also uses rejection sampling to avoid modulo bias. Naively taking a random 32-bit value modulo the range makes the lowest values slightly more likely, because 232 is rarely divisible by the range. Discarding values above the largest exact multiple removes the skew entirely, at the cost of an occasional extra draw.

True Random vs. Pseudo-Random

 True random (TRNG)Pseudo-random (PRNG)
SourcePhysical — thermal noise, radioactive decay, atmospheric noiseA deterministic algorithm from a seed
ReproducibleNoYes, given the same seed
SpeedSlowVery fast
PredictableNoYes, if the seed and algorithm are known
Typical useCryptographic key generation, lotteriesSimulation, games, sampling

A CSPRNG such as the one used here sits between the two: it is algorithmic, but seeded from genuine physical entropy and designed so that observing past outputs gives no useful information about future ones. That is sufficient for every use on this page and for most cryptographic uses too.

Note on JavaScript's Math.random()

The familiar Math.random() is not cryptographically secure. It is fast and statistically adequate for games and simulations, but its internal state can be recovered from a modest number of outputs, making future values predictable. It should never be used for passwords, tokens, shuffling cards for money, or anything where predictability matters. This page uses it only as a fallback in browsers without the crypto API.

Sampling With and Without Replacement

Allowing repeats is sampling with replacement — each draw is independent, and the same value can appear more than once. It models rolling a die repeatedly.

Disallowing repeats is sampling without replacement, which models drawing lottery balls or dealing cards. The calculator uses a partial Fisher-Yates shuffle for this: it shuffles only as many positions as you need rather than the whole range, which is both faster and provably unbiased.

Note that duplicates in a random list are far more common than intuition suggests. Drawing 10 numbers from 1–100 with replacement produces at least one duplicate about 37% of the time. This is the birthday problem in another guise, and it is a frequent reason people wrongly suspect a generator is broken.

Probability of at Least One Duplicate

Drawing n numbers from a range of 100, with replacement:

Numbers drawnChance of a duplicate
21.0%
59.7%
1037.2%
1565.7%
2087.0%
2596.3%
3099.3%

Common Uses

  • Random sampling — selecting participants or records without selection bias.
  • Assigning treatment groups — randomisation is what makes a controlled trial causal rather than correlational.
  • Giveaways and draws — picking a winner from a numbered list.
  • Simulation — Monte Carlo methods estimate answers by running many random trials.
  • Games — dice rolls, card shuffles, loot drops.
  • Load testing and fuzzing — generating unpredictable inputs to find edge cases.

What Random Does Not Mean

People expect random sequences to look evenly spread, and reject genuine randomness as "not random enough" when it clusters. In a truly random sequence of coin flips, a run of six heads appears roughly once every 64 flips. Streaks, clusters and repeats are what randomness actually produces; their absence is what should look suspicious.

The related error is the gambler's fallacy: believing that a run of low numbers makes a high number "due". Independent draws have no memory. The next value is exactly as likely as it was before, regardless of what came before it.

Frequently Asked Questions

Are the numbers really unpredictable?

For all practical purposes, yes. The browser's crypto API is seeded from operating-system entropy and is designed to resist prediction even by an attacker who has seen many prior outputs.

Can I get the same numbers again?

No. There is no seed input, deliberately — a reproducible sequence would defeat the purpose for draws and selections. If you need reproducibility for a simulation, use a seeded PRNG in your own code.

Is this fair enough for a prize draw?

The generator itself is sound. For anything with legal or financial consequence, the usual requirement is an auditable process — witnesses, recorded seeds, or a certified third-party service — rather than a stronger generator.

Why is the mean of my numbers not exactly the middle of the range?

Because random samples vary. The mean converges on the midpoint only as the count grows; with five numbers, a wide deviation is entirely normal.