Random Number Generator
Use this free Random Number Generator to calculate your Random numbers instantly and accurately.
Settings
Random numbers
What is a Random Number Generator?
A Random Number Generator produces unpredictable numbers within a user-defined range using cryptographically secure randomness. It supports drawing single numbers or sets of numbers, with or without repeats. This tool is useful for lotteries, raffles, statistical sampling, gaming, cryptography, and any application requiring unbiased random selection.
How to calculate random number generation (the formula)
A uniform random integer between min and max (inclusive) is generated using: result = min + floor(random × (max - min + 1)), where random is a cryptographically secure floating-point value in [0, 1). For unique draws without replacement, the Fisher-Yates shuffle algorithm is used: initialize an array with all numbers in the range, then randomly swap elements from end to start, picking the last k elements.
Example calculation
Generate 3 unique random numbers between 1 and 10. The Fisher-Yates shuffle on [1,2,3,4,5,6,7,8,9,10] might produce: [5, 2, 9, 7, 1, 10, 4, 8, 3, 6], then take the first 3: [5, 2, 9]. For 6 non-unique numbers between 1 and 6 (simulating a die rolled 6 times): [3, 1, 6, 3, 2, 5]. The sum is 20 and the average is 3.33.
Common mistakes
- Using Math.random() for security — Math.random() is pseudo-random and predictable. Always use crypto.getRandomValues() for passwords, tokens, or any security-related randomness.
- Off-by-one errors in range — Ensure the range is inclusive. Generating between 1 and 10 should include both 1 and 10. The formula is:
min + floor(random × (max - min + 1)). - Generating unique numbers when the range is too small — If you request 10 unique numbers from a range of 1-5, it's impossible. The tool caps the count to the available range size.
Frequently asked questions
How are random numbers generated?
The tool uses crypto.getRandomValues() for cryptographically secure random numbers, not pseudo-random algorithms.
Can I generate numbers without repeats?
Yes, enable the unique mode to draw numbers without replacement from the specified range.
What is the difference between true random and pseudo-random?
True random uses physical entropy; crypto.getRandomValues() is cryptographically strong and suitable for secure applications.
What is the maximum range supported?
The range depends on JavaScript's Number precision; practically up to 9 quadrillion.
Can I generate numbers for a lottery?
Yes, use unique mode to draw non-repeating lottery numbers from any range you define.
How many numbers can I generate at once?
The tool supports generating up to 100 numbers in a single run.