Random Number Generator
Generate random numbers, roll dice, or flip a coin.
Click the number to generate a new one
About the Random Number Generator
This generator uses the browser's crypto.getRandomValues() API to produce cryptographically secure random numbers — the same quality of randomness used in security applications. Unlike Math.random(), which uses a pseudo-random algorithm seeded by the system clock, crypto.getRandomValues() draws from the operating system's entropy pool, making each result genuinely unpredictable.
Common uses for random number generation
- Lotteries and draws — pick a winner from a group or draw raffle numbers fairly
- Dice rolling — simulate d6, d10, d20 and other dice for tabletop games
- Statistical sampling — randomly select a subset from a population for research
- PIN generation — generate secure numeric codes for temporary access
- A/B testing — randomly assign users to control and test groups
Pseudo-random vs cryptographically random
Most programming language default random functions are pseudo-random — deterministic sequences that appear random but are generated from a seed. For security purposes (tokens, passwords, OTPs), always use a CSPRNG: secrets.randbelow() in Python, or crypto.getRandomValues() in JavaScript.
Randomness in statistics and simulation
Random number generators are the foundation of Monte Carlo simulation, statistical sampling, and probabilistic modelling. In finance, Monte Carlo methods simulate thousands of portfolio paths to estimate risk. In medicine, randomised controlled trials use random allocation to prevent bias. Simulation games and procedural generation use seeded pseudo-random generators to create reproducible "random" worlds.
- Monte Carlo simulation — run thousands of random scenarios to estimate probability distributions of outcomes
- Random sampling — select a representative subset from a population without systematic bias
- A/B testing — randomly assign users to control and test groups to measure the effect of a change
- Seeded randomness — using a fixed seed produces the same "random" sequence every time, useful for reproducible experiments
Frequently Asked Questions
import random; random.randint(1, 100). JavaScript: Math.floor(Math.random() * 100) + 1. For cryptographically secure: Python: import secrets; secrets.randbelow(100) + 1. JavaScript: use Uint32Array with crypto.getRandomValues().