Random Number Generator
Generate random numbers within a specified range.
Input Information
Result
Please generate numbers.
Random Number Generator A tool that picks random numbers within a specified range. Set min, max, count, and choose duplicate/sort options to create numbers for drawings, sampling, test data, and more.
Useful for random number generation, prize draws, A/B test sampling, simulation random numbers, and game event probability verification.
Essential for developers and data analysts as a test data tool, and for event organizers and educators as a fair drawing tool. Recent 10 generation records are also provided.
Generation uses Math.random() for statistically uniform distribution. For security-critical random numbers (official draws, etc.), use a cryptographic random number generator separately. Records are maintained only during the browser session.
- Set the minimum and maximum range for your numbers.
- Enter how many numbers you want to generate.
- Choose whether to allow duplicates and whether to sort the results.
- Click generate and your random numbers are displayed.
Dice Simulation
Set the range 1-6 and count 2 to generate two numbers between 1 and 6, just like rolling a die twice.
Random Selection
Select range 1-100, count 5, and no duplicates to generate 5 unique numbers.
Sorted List
Select range 1-100, count 5, and sort to generate 5 numbers in ascending order.
Base Generation Formula
random = floor(random() × (max - min + 1)) + min
Duplicate Prevention Logic
When duplicates are not allowed, already drawn numbers are tracked using a Set.
No duplicates: (max - min + 1) ≥ count
Generating more than the range limits will be restricted.
Sorting
Array.sort((a, b) => a - b)
When the ascending sort option is enabled, results are organized by size.
Random Selection
- Use no duplicates and ascending sort.
- Set range and count for your specific need.
Fair Drawing
- Allow duplicates to create multiple-draw scenarios.
- Announce the range to participants before the draw.
Test Data
- Create sample input values with random numbers in range.
- Use the record feature for repetitive verification.
Game Use
- Use for event/item drop probability simulation.
- Change the random seed to observe distributions.
Range Caution
- If min > max, they are automatically swapped.
- When no duplicates, ensure count doesn't exceed range.
Secure Random
- Not suitable for official drawing/authentication purposes.
- Use a separate cryptographic random generator when needed.
QIs Math.random() fair?
Math.random() is nearly uniform but not perfectly so. It is fair enough for most everyday uses, but not suitable for security-critical applications.
QCan duplicates be prevented when the count exceeds the range?
No. To generate without duplicates, the count must be less than or equal to the size of the range. An error is shown if the count exceeds the range.
QWhat happens if the minimum is greater than the maximum?
The calculator automatically sorts the two values into the correct range, so it always produces a valid result.
QAre the generated numbers unbiased?
Yes. Each number is selected independently with equal probability, so the results are unbiased and random.
QWhich random numbers should be used for security-critical purposes?
You should use a cryptographically secure random source such as crypto.getRandomValues. Math.random() can be predictable and is not suitable for security.