Free Converter

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

About Random Number Generation

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.

Why Generate Random Numbers

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.

How to Generate Random Numbers

Set range and count, generate.

  1. Set the range: Minimum and maximum values define the inclusive range. Both endpoints are possible outcomes.
  2. Choose count: Number of values to generate. Single values for one-off picks; bulk generation for sampling or test data.
  3. Configure uniqueness: Allow duplicates (each pick is independent) or require unique values (sample without replacement). Unique values require count to be at most the range size.
  4. Generate: The browser produces the values. Display formats: comma-separated list, one per line, or plain numbers depending on use case.

Common Use Cases

Technical Details

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.

Best Practices

Frequently Asked Questions

Is this random truly random?
The crypto-based generator uses the browser's cryptographically secure random source, which is unpredictable in the cryptographic sense. The Math.random fallback is statistically random but predictable to an attacker who can observe output.
What's the difference from Math.random?
Math.random is faster but predictable given enough output (xorshift or similar PRNG). crypto.getRandomValues uses the OS's secure random source. For contests and security uses, prefer crypto.
Are duplicates possible?
By default, yes — each pick is independent. Enable uniqueness mode to sample without replacement.
What ranges are supported?
Any integer range. For very large ranges (over 2^53), JavaScript's number precision becomes a limit; for those use a BigInt-based approach.
Can I generate decimals?
Most generators offer integer mode by default. Decimal mode generates floats in the range; precision depends on the underlying random source.
Is the random source the same across browsers?
Implementation differs but all modern browsers provide cryptographically secure random via getRandomValues. Quality is comparable.
Is my data uploaded?
No. Generation happens in your browser.
Can I seed the random source for reproducibility?
Cryptographically secure sources are not seedable (that would defeat the security). For reproducible random, use a separate PRNG with a chosen seed; not appropriate for contest or security uses.