Skip to main content
CheckTown
Generators

Random Number Generator: Truly Unbiased Numbers Online

Published 5 min read
In this article

What Is Random Number Generation?

Random number generation is the process of producing numbers that cannot be predicted in advance. Computers are deterministic machines — they cannot produce true randomness without external input. Different techniques produce different qualities of randomness, which matters greatly for security applications.

True random number generators (TRNGs) harvest entropy from physical phenomena: mouse movement, keyboard timing, network packet arrival times, or dedicated hardware sensors. Pseudo-random number generators (PRNGs) use mathematical algorithms seeded with entropy to produce sequences that appear random.

How Random Numbers Are Generated

CheckTown uses the browser's cryptographically secure random number generator.

  • Entropy source — uses window.crypto.getRandomValues() which draws from OS-level entropy
  • Range mapping — maps raw random values to your specified min/max range without bias
  • Batch generation — generate multiple numbers at once for lists, arrays, or bulk needs

Try it free — no signup required

Generate Random Numbers →

When To Use a Random Number Generator

Random number generation has many applications across development, testing, and statistics.

  • Testing — generate random test data to populate fixtures or seed test databases
  • Sampling — select random samples from datasets for statistical analysis or A/B test assignment
  • Games and simulations — generate unpredictable inputs for simulations, games, or lotteries

Frequently Asked Questions

What is the difference between Math.random() and crypto.getRandomValues()?

Math.random() uses a fast PRNG seeded at startup. It is suitable for simulations and games but not for security. crypto.getRandomValues() uses the OS's CSPRNG (Cryptographically Secure PRNG) which is suitable for generating tokens, keys, and other security-sensitive values. Always use crypto.getRandomValues() for security purposes.

Can I use random numbers for cryptographic keys?

Yes, but only if generated with a CSPRNG. Random numbers from Math.random() or similar non-cryptographic PRNGs are predictable given the seed and enough output samples. Cryptographic keys, tokens, salts, and nonces must be generated with cryptographically secure randomness.

What is modulo bias and how does it affect random number ranges?

Modulo bias occurs when mapping a random value to a range using the % operator. If the random value space is not evenly divisible by the range size, some values appear more frequently than others. For example, mapping 0-255 to 0-9 using % 10 causes 0-5 to appear slightly more often. CheckTown uses rejection sampling to eliminate bias.

Related Tools