PureDevTools

Random Number Generator

Generate cryptographically secure random numbers — integers, floats, dice rolls, bulk export

All processing happens in your browser. No data is sent to any server.

You need 50 random integers between 1 and 10,000 for a load-testing seed file. Math.random() is fast but not cryptographically secure, and writing a rejection-sampling loop every time is tedious. You need a tool that generates unbiased, crypto-quality random numbers with configurable ranges and bulk output.

Why Not Just Use Math.random()?

Math.random() is a pseudo-random number generator (PRNG). Its output is deterministic — given the same internal state, it produces the same sequence. This makes it unsuitable for security-sensitive applications like token generation, lottery systems, or cryptographic key derivation.

This tool uses the Web Crypto API (crypto.getRandomValues()) which draws entropy from the operating system’s secure random source. The result is indistinguishable from true randomness for all practical purposes.

How Unbiased Range Generation Works

Generating a random integer in a range like 1–100 seems simple: take a random number modulo 100 and add 1. But this introduces modulo bias — if the random source’s range isn’t evenly divisible by 100, some values appear slightly more often than others.

This tool uses rejection sampling: it generates random values and discards any that fall outside the largest multiple of the range that fits within the source’s output space. The accepted values are perfectly uniformly distributed.

Generation Modes

ModeOutputExample
Integer rangeWhole numbers between min and max (inclusive)1–100 → 47
Float rangeDecimal numbers with configurable precision0.0–1.0 → 0.73821
Dice rollStandard dice notation (NdS)3d6 → 4, 2, 6 (sum: 12)
BulkMultiple results at once50 integers, one per line

Entropy and Security Strength

The security of a random number depends on the entropy of the source. The Web Crypto API provides at least 128 bits of entropy per call, which is the minimum recommended for security applications. For context:

EntropyBrute-Force Time (1 trillion guesses/sec)
64 bits~0.5 hours
128 bits~10^16 years
256 bits~10^53 years

For non-security use cases (simulations, games, sampling), the entropy level is more than sufficient.

Use Cases

Load testing and simulation. Generate thousands of random inputs for stress tests, Monte Carlo simulations, or statistical sampling. Export as newline-separated values and pipe directly into your test scripts.

Game development. Fair dice rolls, card shuffles, random map seeds. Cryptographic randomness ensures no player can predict outcomes even with knowledge of previous results.

Lottery and raffle systems. When fairness matters legally or ethically, crypto-quality randomness is the standard. This tool provides auditable, unbiased results.

Educational purposes. Teach probability distributions by generating large samples and checking uniformity. A good random generator should produce a flat histogram over enough trials.

Privacy

All number generation runs entirely in your browser using the Web Crypto API. No numbers, ranges, or settings are transmitted to any server. You can verify this by checking your browser’s network tab — zero outbound requests during generation.

Frequently Asked Questions

What is the maximum range I can use? The tool supports integers up to JavaScript’s safe integer limit: 2^53 − 1 (9,007,199,254,740,991). For most practical purposes this is effectively unlimited.

Is this suitable for generating cryptographic keys? This tool uses cryptographic-quality randomness, but generating cryptographic keys requires careful handling of key material (secure memory, proper encoding, key derivation functions). Use a dedicated cryptographic library for key generation.

How many numbers can I generate at once? Bulk mode supports up to 10,000 numbers per generation. All results can be copied to clipboard as a newline-separated list.

Can I generate random floats with specific decimal places? Yes. Set the precision to control how many decimal places appear in the output. The underlying randomness is still crypto-quality.

Is the output truly random? The Web Crypto API provides cryptographic-quality pseudorandomness backed by OS-level entropy sources. It is considered indistinguishable from true randomness for all practical and cryptographic purposes.

Related Tools

More Text & String Tools