🎲 Random Number Generator

Generate cryptographically strong pseudorandom integers using the Web Crypto API — with rejection sampling to eliminate modulo bias. Single, multiple, dice, and lottery modes. All processing runs in your browser.

What Is a Random Number Generator?

This tool generates secure, unpredictable random numbers using the Web Crypto API (crypto.getRandomValues()) — not Math.random(). You specify a minimum and maximum value, a count, and whether numbers should repeat. The output is one or more integers, produced entirely in your browser. The generator supports four modes: single (one number), multiple (a list with optional uniqueness), dice (RPG-style rolls with d4 through d100), and lottery (unique picks from a pool, sorted). Because the values come from a cryptographically strong pseudorandom source, they are far less predictable than typical browser-based generators — but they are not deterministic hardware "true random" values.

Random Source: Web Crypto, Not Math.random

This generator uses crypto.getRandomValues(), the browser's built-in cryptographically secure pseudorandom number generator (CSPRNG). Most online random number tools rely on Math.random(), which is a fast, deterministic algorithm designed for games and visual effects — not for situations where unpredictability matters.

Key differences:

What the tool does NOT offer: It does not provide hardware "true random" values (derived from physical entropy measurements). It cannot guarantee absolute unpredictability against all attack models. For cryptographic key generation or security token creation, use a dedicated cryptographic library — not a browser-based integer generator.

Result

📜 History

No generations yet

📌 Embed This Tool

Add the Random Number Generator to your website for free. Just copy and paste the code below.

When to Use This Generator

This tool is useful whenever you need unbiased random integers from a specified range, without installing software or trusting a server-side generator:

When NOT to use this tool: If you need cryptographic keys, authentication tokens, or password material, use a dedicated security library or the Password Generator. This tool produces raw integers — not formatted token strings, not salted hashes, and not key material suitable for production cryptography.

How It Works

The generator follows a five-step pipeline, all running locally in your browser:

  1. Input validation. The minimum, maximum, and count values are parsed as integers. If the minimum exceeds the maximum, the tool silently swaps them. Invalid entries fall back to default values.
  2. CSPRNG generation. The browser's crypto.getRandomValues() fills a Uint32Array with cryptographically strong random bytes.
  3. Rejection sampling. To prevent modulo bias, values that fall into the incomplete final "bucket" of the range are discarded and re-rolled. This ensures every integer in the range has a statistically equal chance of being selected.
  4. Range mapping. The accepted random value is mapped to the requested [min, max] range using a simple modular projection: min + (random_value % range).
  5. Display and copy. Results are rendered on screen, saved to an in-memory history (last 10 generations), and available for manual copy. No results are sent to any server.

How to Use the Random Number Generator

1. Pick your mode. Choose from Single (one random number), Multiple (a list), Dice (RPG-style rolls), or Lottery (unique picks from a pool). Each mode has its own input fields.

2. Set your parameters. Enter the minimum and maximum range, the number of results you want, and whether numbers should be unique. Dice mode lets you pick the number of dice and sides (d4 through d100).

3. Click Generate. Press the "Generate" button or just switch modes to see results instantly. All numbers are drawn from the Web Crypto API — a cryptographically secure pseudorandom source, far stronger than Math.random().

4. Review your history. The last 10 generations are saved in the History panel below the result display, with timestamps and mode labels. Click "Clear" to start fresh.

Limitations

Privacy

All random number generation runs entirely in your browser. Your min, max, count, and unique settings — and the resulting numbers — never leave your device. No external random-number API or server-side computation is involved.

ToolStand may record anonymized page-view and tool-interaction analytics (such as which mode was used), but the actual generated numbers are never collected, logged, or transmitted. The analytics system tracks feature usage, not user data.

Frequently Asked Questions

Is this random number generator truly random?

It is cryptographically secure pseudorandom, not hardware "true random." The tool uses crypto.getRandomValues(), which the browser seeds from the operating system's entropy pool. This is far stronger than Math.random() and is the same API used by cryptographic applications — but it is still a deterministic algorithm, not a physical entropy source.

Is Web Crypto better than Math.random?

Yes, for any situation where unpredictability matters. Math.random() is fast and simple — its internal state can be reconstructed from observed output, making future values predictable. crypto.getRandomValues() is designed to resist state-recovery attacks and is suitable for cryptographic applications. For casual use (games, visual effects), both work. For security-sensitive uses (lotteries, random draws, statistical sampling), Web Crypto is the correct choice.

Can I use these numbers for passwords or security tokens?

Not directly. This tool produces raw integers, not formatted passwords or cryptographic tokens. For password generation, use the dedicated Password Generator. For cryptographic key material, use a proper cryptographic library (OpenSSL, libsodium, or your platform's CSPRNG byte extractor) — not a browser-based integer generator.

Why can the same number appear more than once?

In "Multiple" mode without the Unique numbers only checkbox, each draw is independent. The same number can be selected multiple times — this is mathematically correct for random sampling with replacement. Enable the "Unique" checkbox to guarantee distinct values (using a Fisher-Yates shuffle behind the scenes).

Does the tool remove modulo bias?

Yes. When mapping a raw Uint32 random value to your requested range, naive modular arithmetic (value % range) would give lower numbers a slightly higher probability. This tool uses rejection sampling: it discards values that fall into the incomplete final "bucket" and re-rolls until it gets a value that maps evenly. Every integer in your range has a statistically equal chance.

Is my random number input sent to a server?

No. All computation — input validation, CSPRNG generation, rejection sampling, and range mapping — runs locally in your browser using JavaScript. No data is transmitted to any server during random number generation. ToolStand analytics records page views and feature interactions but never collects the numbers you generate.

Related Tools