π² Random Number Generator
Generate cryptographically random numbers, dice rolls, and picks.
How to Use This Tool
Select the tab for the type of number you need: Integer, Decimal, Unique Set, or Dice/Coin. Fill in the range and count, then click Generate. Results appear below the controls.
Choose a tab: Integer for whole numbers, Decimal for floating-point values, Unique Set for non-repeating picks, or Dice/Coin for quick rolls.
Set the min and max range, and the count of numbers to generate.
Click Generate to produce the result, which displays in the result card below.
For dice and coin: click the d6, d10, d20, d100, or Coin Flip buttons directly for an instant result.
Cryptographic Randomness vs Math.random()
Most programming tutorials use Math.random() for generating random numbers, but that function uses a pseudorandom number generator (PRNG) seeded at startup. It is fast and statistically uniform, but it is not unpredictable: given enough output values, the internal state can be determined and future values predicted. For most applications this does not matter, but for anything involving fairness (giveaways, lotteries, shuffles in competitive games) or security (tokens, keys, salts), predictability is a real problem. This tool uses crypto.getRandomValues(), which draws from the operating system's entropy pool fed by hardware events like mouse movements, disk timings, and network interrupts. The OS entropy pool is designed to be unpredictable even to an adversary with access to the system. The uniform integer algorithm avoids modulo bias, a subtle flaw where naively computing randomInt % N makes smaller values slightly more probable when the pool size is not a multiple of N. This tool uses rejection sampling to ensure every integer in the range has exactly equal probability.
Common Use Cases
Frequently Asked Questions
Are these numbers truly random?
They use window.crypto.getRandomValues() β a cryptographically secure pseudorandom number generator (CSPRNG). For most purposes this is equivalent to true randomness.
What is the difference between random and pseudo-random?
True random numbers come from physical entropy (radioactive decay, atmospheric noise). CSPRNG uses mathematical algorithms seeded with high-quality entropy β indistinguishable from true random for most uses.
Can I generate lottery numbers?
Yes β use the "Unique Set" mode with your lottery's range to get non-repeating picks.
What is a random seed?
A seed is a starting value for a pseudorandom generator. The same seed always produces the same sequence β useful for reproducible simulations.
How do I simulate a dice roll?
Use min=1, max=6 for a standard d6. Max=20 for a d20 (D&D). Max=100 for a percentile die.