Random Number Generator
Generate random numbers instantly in your browser. Customize range, count, and format. Free, private, and no data sent to any server.
Generate
Generate random numbers instantly in your browser. Customize range, count, and format. Free, private, and no data sent to any server.
Generate
Random number generators produce numbers within a specified range with no predictable pattern. Common applications include rolling dice, picking lottery numbers, sampling for statistical work, generating test data, and any context where an unbiased pick is needed. The quality of the randomness depends on the source: weak sources can produce numbers that look random but have detectable patterns; strong sources are unpredictable to even sophisticated analysis.
This generator uses the browser's cryptographically secure random source (window.crypto.getRandomValues) for security-relevant uses, with optional Math.random fallback for entertainment uses where speed matters more than security. For dice rolls, contest picks, or anything that affects outcomes, the secure source is the right choice.
Output range and count are configurable. Generate one number, several at once, or a sequence with optional uniqueness (no duplicates). Output formats include plain numbers, comma-separated lists, and one-per-line text.
Many small decisions benefit from unbiased random selection. Picking a winner for a contest, deciding which restaurant to try, randomizing the order of test cases, sampling rows from a dataset — all are improved by a random number generator that excludes human bias.
Statistical and scientific work also depends on quality randomness. Monte Carlo simulations, A/B test bucket assignment, randomization of test inputs, and many other techniques need numbers that are statistically uniform and unpredictable to the system being studied.
Set range and count, generate.
Random integer generation: get a random byte (or word) from crypto.getRandomValues, apply rejection sampling to avoid modulo bias, map to the desired range. Plain modulo without rejection sampling produces slight bias for ranges that don't divide evenly into the source's range; rejection sampling avoids this.
Bias-free uniform integer generation: generate random byte, if byte > floor(256/range) × range, reject and try again, otherwise return byte mod range. The rejection rate is at most 50% on average, so the algorithm is practically fast even for awkward ranges.
Math.random vs crypto.getRandomValues: Math.random is faster but uses xorshift or similar PRNGs that can be predicted given enough output. crypto.getRandomValues is cryptographically secure. For non-security use (dice, casual picks), either works; for security, use crypto.