stoolme
Home/ Generator/ Random number generator

Random number generator

Generate one or many random integers in a chosen range. Uses crypto.getRandomValues for true unpredictability.

What this tool does

Generates one or many integers in the range you specify, uniformly and unpredictably, using your browser's cryptographic random number generator (crypto.getRandomValues).

Why "cryptographic" matters

JavaScript's Math.random() uses a pseudo-random generator that's fine for animation and shuffling card games, but it's seeded predictably and produces a sequence an attacker could replay. crypto.getRandomValues draws from the operating system's true-entropy source (mouse jitter, network timing, hardware RNGs on modern CPUs). The output cannot be predicted even if you know all the inputs.

Modulo bias — and how this tool avoids it

The naive way to get a random number in a range — take a big random number and modulo it — introduces a small bias toward the low end of the range when the range doesn't divide evenly into 2³². This tool uses rejection sampling: it discards values that would cause bias and retries until it gets one in the safe zone. This is slightly slower but mathematically uniform.

When to use unique-only mode

Turn on "Unique values only" when you want a sampling without replacement — e.g. picking 5 winners from a list of 100 entries, or drawing 6 lottery numbers from 1 to 49. The tool will refuse to generate more unique values than the range allows.

Examples

  • Coin flip: min 0, max 1.
  • Six-sided die: min 1, max 6.
  • Lottery numbers: min 1, max 49, count 6, unique.
  • Picking from a list of 200: min 1, max 200, count 1 or many, unique.
  • Random IP-address-like octet: min 0, max 255.

Privacy

Generation is entirely local.

Frequently asked questions

Is this really random?
It is cryptographically unpredictable, which is the strongest practical definition of randomness in software. The underlying source mixes operating-system entropy, hardware RNGs, and other unpredictable inputs.
What's the difference vs Math.random()?
Math.random() is fast and good enough for animation, but seeded predictably and not safe for security-relevant use. crypto.getRandomValues, which this tool uses, is suitable for cryptographic purposes.
Can I generate decimals?
Not in this tool — integers only. If you need decimals, generate two integers and divide.
What's the maximum range?
The minimum and maximum can be any 32-bit signed integers (about ±2 billion). The result is computed without bias regardless of the range size.
Are the numbers truly unique when "Unique only" is on?
Yes. Duplicates are detected and re-rolled. If you ask for more unique values than the range can supply, the tool refuses with an error.