Many everyday decisions need a number that nobody can predict or manipulate: a prize draw, a lottery, a random sample, a shuffled order, or a test case. An ordinary random function is not good enough for those cases, because its output can be biased or predictable, and a biased draw is an unfair draw. The Secure Random Number Generator produces numbers with the browser cryptographic random number generator, using rejection sampling so that every number in your chosen range is equally likely, with no modulo bias. You set a minimum, a maximum, and how many numbers you need, and you can require unique numbers or sorted results. The numbers are generated locally and never leave your browser.
What Is the Secure Random Number Generator?
The Secure Random Number Generator is a free browser-based tool that generates unbiased random integers within a range you specify. The key word is unbiased. A naive way to generate a random number in a range is to take a large random value and compute the remainder when dividing by the range size. That method, called modulo reduction, favors some numbers over others when the range does not divide the maximum value evenly, a flaw known as modulo bias. The difference may be tiny for a single draw, but it is real, and for draws where fairness matters, even a small bias is unacceptable. This tool avoids the flaw with rejection sampling: it draws a 32-bit random value, discards it if it falls in the leftover region that would cause bias, and draws again, until the value falls in the fair region. Every number in the range then has exactly the same probability.
The range can be large: the minimum defaults to 1 and the maximum to 100, but you can set any integer range whose size is within about four billion values, and the tool shows an error if the range is too large for its 32-bit sampling method. You can request between 1 and 1000 numbers. The Unique numbers option guarantees no repeats, by drawing until the requested count of distinct values is reached, and the tool shows an error if you request more unique numbers than the range contains. The Sort results option orders the numbers from smallest to largest after generation, which is convenient for draws, samples, and lists that will be compared or published. Results are shown as a comma-separated list in a large display, with a Copy Results button that copies the list in the same format.
The tool requires the Web Cryptography API over HTTPS in a modern browser, and it explains the requirement if the API is unavailable. The hint below the tool states the intended uses plainly: draws, lotteries, and other cases where fairness matters. That is the distinction between this tool and a casual random number tool: this one is built for cases where the fairness of the result could be questioned or contested.
How to Use the Secure Random Number Generator
- Set the minimum. Enter the smallest number that may be generated in the Minimum field. The default is 1. The minimum can be negative, zero, or positive, as long as it is less than or equal to the maximum.
- Set the maximum. Enter the largest number that may be generated in the Maximum field. The default is 100. Both endpoints are inclusive: the minimum and the maximum can both appear in the results.
- Choose how many numbers to generate. Enter a number from 1 to 1000 in the How many numbers field. The default is 1. Larger counts are useful for samples, simulations, and draws with many winners.
- Decide about uniqueness. Tick Unique numbers (no repeats) if each number must appear at most once, as in a draw without replacement. Leave it unticked if repeats are allowed, as in dice rolls or repeated sampling.
- Decide about sorting. Tick Sort results if you want the numbers in ascending order. Leave it unticked to preserve the order in which numbers were drawn, which matters if the order itself is part of the result, such as a ranked draw.
- Click Generate. Press the Generate button. The numbers appear in the large display, separated by commas.
- Copy the results. Use the Copy Results button to copy the comma-separated list for pasting into a document, a spreadsheet, or a message. If you need a different format, paste the list and adjust separators in your editor.
Key Features of the Secure Random Number Generator
- Unbiased sampling. Rejection sampling over 32-bit cryptographic random values guarantees that every number in the range is equally likely, with no modulo bias.
- Cryptographic source. Numbers come from the browser cryptographic random number generator, designed for security-sensitive use, not from a predictable pseudo-random function.
- Wide range support. Ranges up to about four billion values are supported, covering everything from dice rolls to large identifier spaces, with a clear error if the range is too large.
- Up to 1000 numbers per run. Generate large samples and multi-winner draws in a single operation.
- Unique-numbers mode. Guarantee no repeats, with validation that prevents requesting more unique numbers than the range contains.
- Optional sorting. Order results ascending for publication or comparison, or keep draw order when the sequence matters.
- Inclusive endpoints. Both the minimum and the maximum can be generated, so the range you specify is exactly the range of possible results.
- One-click copying. The comma-separated result copies cleanly into spreadsheets, documents, and messages.
Practical Use Cases With Concrete Examples
Running a prize draw. A school raffle has 250 tickets numbered 1 to 250 and needs three winners. Set the range to 1 to 250, request 3 unique numbers, and generate. The unbiased sampling means every ticket has the same chance, and the unique option ensures no ticket wins twice. Record the result and the method for transparency.
Picking a random sample for an audit. An auditor needs to inspect 20 invoices out of 1,000. Set the range to 1 to 1,000, request 20 unique numbers, and sort the results. The sorted sample is easy to work through in order, and the random selection avoids the bias of choosing convenient or familiar items.
Simulating dice and games fairly. A game night needs a fair 20-sided die roll. Set the range to 1 to 20 and generate one number. For a board game that needs many rolls, generate a batch and use them in order, preserving the sequence by leaving sorting off.
Assigning random groups. A teacher has 30 students and wants to assign them to groups. Generate the numbers 1 to 30 as unique values, then assign students in that shuffled order to groups in rotation. The random order prevents friends clustering together by seating or alphabetical order.
Creating test data. A developer testing a system that accepts values in a range needs unbiased test inputs, including edge cases. Generate batches across the full range, including the endpoints, to verify that the system handles minimum, maximum, and middle values correctly.
Choosing a random winner from entries. A social media giveaway has 1,843 entries numbered in order. Generate one number in the range 1 to 1,843. The cryptographic source and unbiased method make the choice defensible if a participant questions the fairness of the draw.
Sampling for quality control. A small manufacturer checks every twentieth item plus a random sample. Generate unique numbers to select additional items for inspection, ensuring the sample is not influenced by production order or operator habit.
Tips and Best Practices
- Document the draw. For any contested draw, record the range, the count, whether uniqueness and sorting were used, the date and time, and the result. Transparency about the method is as important as the randomness itself.
- Use unique mode for draws without replacement. If each entry can win only once, tick the unique option. If repeats are allowed, such as repeated dice rolls, leave it unticked.
- Keep draw order when order matters. Sorting is convenient, but it destroys information about the sequence. If first, second, and third place matter, leave sorting off and record the order as generated.
- Check the range before generating. An off-by-one error in the minimum or maximum changes the result. Confirm that both endpoints are included as intended, and that the count does not exceed the range when uniqueness is required.
- Do not use the result as a password or key. Random numbers are for selection and sampling. For credentials, use the Password Generator, and for keys, use the Secret Key Generator, which are designed for those purposes.
- Re-generate rather than editing results. If a result is unusable because an entry was invalid, generate a fresh replacement rather than picking a nearby number by hand. Hand adjustments reintroduce bias.
- Understand that fairness requires a fair process around the tool. The tool guarantees unbiased numbers, but the draw is only fair if the numbering of entries is complete, the result is recorded honestly, and the draw is not repeated until a preferred outcome appears.
Limitations
The Secure Random Number Generator produces integers only; it does not generate decimal numbers, and it does not shuffle lists or pick names directly. For list shuffling, generate a set of unique numbers and use them as positions. The range is limited to about four billion values by the 32-bit sampling method, and the count is limited to 1000 numbers per run. Unique mode can be slow if the requested count is close to the range size, because many draws will repeat values already seen, although for typical draws this is not noticeable. The tool does not record results, provide a verifiable audit trail, or timestamp draws; if you need an auditable record, you must create it yourself by documenting the parameters and result. It requires WebCrypto over HTTPS in a modern browser. Finally, the tool guarantees unbiased numbers, but it cannot guarantee a fair process: if entries are numbered dishonestly, if the draw is repeated selectively, or if the result is altered afterwards, the fairness is lost regardless of the quality of the random source.
Frequently Asked Questions
What is modulo bias, and why does it matter?
Modulo bias happens when a random value is reduced to a range with the remainder operation, and the range does not divide the maximum evenly, so some numbers become slightly more likely. This tool uses rejection sampling to discard values that would cause bias, so every number is equally likely.
Can the minimum and maximum both appear in the results?
Yes. Both endpoints are inclusive. A range of 1 to 100 can produce 1, 100, and every value in between, each with the same probability.
What happens if I request more unique numbers than the range contains?
The tool shows an error explaining that the request is impossible, and does not generate numbers. Reduce the count or widen the range, and try again.
Why is there a limit of 1000 numbers?
The limit keeps the tool responsive and the result readable. If you need more than 1000 numbers, generate them in multiple runs and combine the lists, bearing in mind that uniqueness is enforced only within each run.
Is this tool suitable for a lottery?
The sampling method is suitable for draws where fairness matters, including lotteries and raffles, provided the surrounding process is fair and documented. For regulated lotteries, check whether local rules require a certified drawing system or independent oversight.
Does the tool store my results?
No. Numbers are generated in your browser and never sent anywhere. Copy the results before you generate again or leave the page, because the tool keeps no history.
Randomness, Fairness, and Trust in Draws
A fair draw is as much a social process as a mathematical one. Participants must believe the result was not manipulated, and that belief rests on transparency: announcing the method in advance, conducting the draw in the open or recording it, and publishing the parameters and the result so anyone can see that the rules were followed. The unbiased sampling in this tool supports that transparency, because the method can be described honestly: numbers were drawn with a cryptographic random generator using rejection sampling, so every number was equally likely. What the tool cannot provide is proof that the draw was conducted once, that the result was not discarded and redrawn, or that the entry list was complete. Those assurances come from witnesses, recordings, and published records. For high-stakes draws, consider having an independent observer, drawing live, and publishing the result immediately. For low-stakes draws, a written record of the range, count, options, and result is usually sufficient. In both cases, the principle is the same: the random numbers are trustworthy only to the extent that the process around them is trustworthy, and documenting the process is part of running a fair draw, not an optional extra.
Related Tools
Related tools include the Random Number Generator for casual random numbers, the Dice Roller for game rolls, the Lottery Number Generator for lottery picks, the PIN Code Generator for numeric codes, and the Secure Token Generator for random tokens. Browse all tools from the homepage.