Random Number Generator
Pick random integers between any two values, in any quantity, with or without duplicates — perfect for raffles, drawings, sampling, dice rolls, and games.
Turn off for raffles, drawings, or unique picks
Pick a minimum, a maximum, and how many numbers you need. Toggle duplicates on for independent draws (dice-roll style) or off for unique picks (raffles, drawings, sampling). Every batch is generated instantly in your browser using the same secure randomness your browser uses for one-time codes, and you can copy the result to the clipboard with one click.
Common uses for a random number generator
Raffles and giveaways are the most obvious case. Number every entry from 1 to N, turn duplicates off, and draw as many winners as prize slots. The result is repeatable enough to defend — screenshot the range, count, and output — and unpredictable enough that no participant can game it.
Teachers use it to cold-call students without bias, assign presentation order, split classes into groups, and generate practice problem sets. Researchers use it to draw random samples from a numbered population, assign participants to control and treatment groups, or shuffle survey question order to control for ordering effects.
Game designers and tabletop players use it as a browser-based replacement for physical dice. A d20 is just a random integer from 1 to 20; a percentile die is 1 to 100. Dungeon Masters can pre-roll a batch of encounter checks before a session so play doesn't stall.
Software engineers reach for it when they need seed values for tests, quick sample data, or a random port number during local development. Marketers use it for A/B bucket assignment when they don't want the overhead of a full experimentation platform.
How the algorithm works — and why 'secure' matters
The generator uses the Web Crypto API's crypto.getRandomValues() when available. That's the same source browsers expose for generating cryptographic keys, session tokens, and one-time passcodes, and it draws from the operating system's cryptographically secure random number generator (CSPRNG) — /dev/urandom on Linux, BCryptGenRandom on Windows, SecRandomCopyBytes on macOS.
For each draw, the generator asks the CSPRNG for a 32-bit unsigned integer, then maps it into your requested range using modulo arithmetic. The 32-bit output has about 4.3 billion possible values, so for any range up to a few million, the modulo bias is negligible — well under one part in a thousand.
The fallback path uses Math.random(), which is a pseudo-random number generator seeded from an unspecified source (typically clock jitter and process state). It's fine for games and sampling but is not appropriate for anything a determined adversary could try to predict — cryptographic key material, session tokens, or high-stakes drawings.
'Without replacement' mode uses a Set to track drawn values and rejection sampling to skip duplicates. When the requested count approaches the size of the range, this can slow slightly, but for typical use (drawing 10 winners from 500 entries, say) the extra work is invisible.
Tips for defensible draws
Fix your parameters before you draw. Screenshot the range, count, and duplicates setting alongside the result, so participants can see exactly what was rolled. Changing the range after the fact — even by one — invalidates the fairness of the draw in the eyes of your audience.
For contests with legal weight (sweepstakes, promotions bound by state law), use a certified third-party RNG service or a physical drawing witnessed by a notary. The Federal Trade Commission's endorsement guides and most state promotion laws require documented, tamper-evident randomization for prizes above certain thresholds.
For classroom or team use, generate all rolls at the start of the session in one batch and share the list. That prevents anyone from re-rolling until they get a favorable result — the number-one way informal random draws stop feeling random.
If you need to seed something like a Monte Carlo simulation and want the same result later, this tool won't help — it's intentionally unseeded. Use a language-level RNG (numpy.random.default_rng(seed=42), for example) so runs are reproducible.
Frequently asked questions
How does this random number generator work?
Every draw calls your browser's built-in crypto.getRandomValues() when it's available (all modern desktop and mobile browsers), which produces cryptographically secure random bytes. It falls back to Math.random() only on very old browsers. The result is an integer between your minimum and maximum, inclusive on both ends.
Is it truly random?
It's cryptographically pseudo-random — the same standard the Web Crypto API uses for one-time codes, session tokens, and secure key generation. For raffles, giveaways, classroom activities, dice rolls, and everyday sampling this is indistinguishable from 'true' randomness. If you need audited randomness for regulated gambling or a public draw, use a certified RNG service.
Can I generate numbers without repeats?
Yes. Turn off 'Allow duplicates' and every number in the batch will be unique. If you ask for more numbers than the range holds (e.g. 20 unique numbers from 1–10), the generator returns nothing and shows a warning — the request is mathematically impossible.
What's the difference between random with and without duplicates?
With duplicates on, each draw is independent — you could roll three 7s in a row. With duplicates off, the generator samples without replacement, which is what you want for raffles, lottery-style drawings, or picking a random subset of a class or team.
How many numbers can I generate at once?
Up to 10,000 per batch is comfortable in any browser. If you need more, generate several batches and paste them together — the algorithm is O(n) with duplicates on and O(n) expected with duplicates off until the request approaches the size of the range.
Can I use this for a giveaway or contest winner?
Yes — set the range from 1 to the number of entries, keep 'Allow duplicates' off, and generate as many winners as prize slots. Screenshot the result before contacting winners so participants can see the draw was transparent.
Does it work offline?
After the first page load, yes — the entire calculator is client-side JavaScript and needs no server round-trip to draw a number.
Related calculators
Browse all Education →Percentage Calculator
Three modes: X% of Y, A is what % of B, and % change.
GPA Calculator
Calculate your semester or cumulative GPA on a 4.0 scale.
Grade Needed Calculator
Find the GPA you need on remaining coursework to hit a target cumulative GPA.
Fraction Calculator
Add, subtract, multiply, and divide fractions and mixed numbers — results returned simplified, as a mixed number, and as a decimal.
Standard Deviation Calculator
Mean, median, mode, range, sample/population standard deviation, variance, quartiles, IQR, and SEM for any list of numbers.
Course Grade Calculator
Weighted course grade from assignments, quizzes, and exams. Shows current grade plus the score needed on remaining work.
Scientific Calculator
Free online scientific calculator with trig, logs, exponents, square roots, parentheses, and constants pi and e.
Area of a Circle Calculator
Find the area of a circle from its radius, diameter, or circumference with the exact formula A = π × r².