Random Number Generator
Free random number generator (RNG) that produces random integers within any range. Lottery picks, dice rolls, statistical sampling, contest winners.
Share on Social Media:
Random Number Generator: Cryptographic-Grade RNG for Lotteries, Sampling, and Testing
Our free Random Number Generator produces unbiased random integers in any range you specify. Single number, list of N numbers, with or without duplicates, sorted or unsorted, decimal or integer. Backed by the browser's crypto.getRandomValues() API — cryptographic-grade entropy, not the predictable Math.random() pseudo-randomness most online tools use. Browser-only, no upload, no logging of generated values.
Random numbers come up more often than you'd think outside of math class. Lottery number pickers, raffle winner selection, dice and card game simulations, A/B test bucket assignments, password component generation, statistical sampling, randomized test inputs, simulation seeds, contest grand-prize draws, coin-flip tiebreakers, jury-pool selection, fair queue ordering. Every one of those use cases requires unbiased random integers; many of them require cryptographic-grade randomness so the output isn't predictable from prior values.
How the generator works
Modern browsers expose the Web Crypto API at window.crypto.getRandomValues(). This function fills a typed array with cryptographically secure random bytes drawn from the operating system's entropy pool (which mixes hardware sources like CPU timing jitter, interrupt timing, mouse/keyboard input, network packet arrival times). Output is suitable for password generation, cryptographic key derivation, and any context where predictability would be a vulnerability.
Our generator allocates a Uint32Array, calls getRandomValues, then maps each 32-bit value into your chosen range via modulo arithmetic with rejection sampling to eliminate modulo bias. Modulo bias is the subtle non-uniformity that emerges when the range size doesn't evenly divide 2³². Most casual RNG implementations have this bug; ours rejects out-of-range values and re-draws, guaranteeing perfect uniformity.
Math.random()'s problem: it's a deterministic pseudo-random number generator seeded from an unspecified source. Two visits to the same page can produce the same sequence; two browsers with the same V8 version produce predictably-correlated streams. For lottery picks or password generation, that's a security failure. Crypto.getRandomValues solves it.
Operating modes
Single number. Set min and max, click Generate, get one integer. Inclusive of both endpoints — Generate(1, 6) returns 1, 2, 3, 4, 5, or 6 each with exactly equal probability.
Bulk list. Set min, max, count. Get a list of N numbers. Toggle "allow duplicates" (default off for lottery-style draws where each number must be unique; on for dice rolls where repetition is normal). Toggle "sorted output".
Decimal mode. Switch from integer to decimal output. Set min, max, number of decimal places. Useful for simulations needing continuous-uniform random variables.
From a list. Paste a list of items (names, IDs, anything), pick N random items. Used for raffle winner selection, A/B test sampling, jury-pool drawing.
Coin flip / dice. Quick-action buttons for common cases: flip a coin (1-2 mapped to H/T), roll a die (1-6), roll multiple dice (e.g., 4d6 for D&D character creation).
Real-world use cases
Lottery / raffle ticket drawing. Set range to the ticket-number range, set count to the number of winners, disable duplicates. Generate. The output is your winners list — cryptographically-fair and reproducible (the timestamp can serve as proof of when the draw occurred).
Contest winner selection. Paste the list of entrants (one per line), set "pick N", click. Output is the winner(s). For high-stakes contests, record the seed (date+time) for transparency.
A/B test bucket assignment. Generate one random number 1-100 per user; assign to variant A (1-50) or variant B (51-100). Crypto-grade RNG ensures buckets are independent of each other and unpredictable.
Statistical sampling. Need to sample 50 random rows from a 10,000-row spreadsheet for QA? Generate 50 unique integers in 1-10000, sorted, then pick those row numbers. The sample is unbiased.
Dice rolls for tabletop games. Online D&D, Pathfinder, Warhammer. Roll 4d6 (keep highest 3) for character stats — input "4 numbers in 1-6", generate, take the top 3. Fair, fast, no physical dice needed.
Card draw simulation. Need to "shuffle a 52-card deck"? Generate 52 unique integers in 1-52. Map them 1-to-1 with cards. The result is a fair shuffle.
Password component generation. Strong passwords need cryptographic randomness for character selection. The character-by-character picker uses crypto.getRandomValues internally — same as our dedicated password generator.
Randomized order in a queue. First-come-first-served is fair when arrival timing is independent; for batch processing where order shouldn't favor early submitters, randomize the queue.
Test input generation. Fuzz testing: generate 1000 random integers in [INT_MIN, INT_MAX] to test how your function handles edge cases.
Monte Carlo simulation. Estimate π by drawing random points in [0,1]² and counting how many fall in the unit quarter-circle. Each random point needs two random decimals.
Jury-pool selection. Some jurisdictions use random selection from voter rolls. The court generates random numbers; the corresponding registered-voter records are summoned.
Sports tiebreakers. Coin flip to determine first possession, kickoff side, etc.
Group assignment. Splitting 30 students into 6 study groups of 5: assign each a random integer 1-6.
Random color generation. Generate three random integers in 0-255 for RGB components. Useful for color-palette inspiration or unique avatar background generation.
Lottery number "lucky picks". Some state lotteries let you opt for random number selection at purchase. Use this tool to generate the same kind of pick for personal record.
Edge cases and gotchas
Range size 0 or 1. If min === max, every "random" number is the same. The tool warns instead of running.
Range size larger than 2³². 4.29 billion is the upper bound from a single 32-bit value. For larger ranges (e.g., random number in 1 to 10¹⁵), the tool uses 64-bit BigInt arithmetic with multiple draws.
"Without duplicates" with N > range size. If you ask for 100 unique numbers in range 1-50, that's impossible. The tool errors with a clear message.
Decimal precision. Decimal output is limited to JavaScript double precision (~15-16 significant digits). Beyond that, decimals can't be distinguished.
Reproducibility. The generator is cryptographically random — different on every call. To reproduce a specific draw (for proof of fairness), record the output verbatim, not the seed. There's no seed parameter intentionally — crypto-grade RNG isn't seeded.
Bias from naive modulo. If you computed `random32 % 6` to get a die roll, you'd have a tiny bias because 2³² isn't evenly divisible by 6. Our generator uses rejection sampling to eliminate this bias completely.
Browser RNG quality. All modern browsers (Chrome, Firefox, Safari, Edge) implement crypto.getRandomValues correctly against well-mixed OS entropy. Older browsers without Web Crypto support fall back to Math.random — flagged in the UI.
"Random" perception. True randomness contains streaks that look non-random. Five heads in a row from a fair coin is normal (probability 1/32). Don't reject the RNG if you see what looks like a pattern.
Privacy
All generation happens locally via the Web Crypto API. The numbers you generate, the ranges you specify, the lists you paste — none of it is sent to any server. There's no telemetry. The page is a static HTML/JS bundle.
This matters because some use cases involve sensitive data: lottery ticket numbers, jury IDs, A/B test user identifiers, password components. None of those need to leave your device.
Frequently asked questions
Is this generator actually random? Yes, in the cryptographic sense. It uses browser's Web Crypto API which pulls from the OS entropy pool (mouse jitter, hardware noise, network timing). Output is unpredictable even given perfect knowledge of all prior outputs.
How is this different from Math.random()? Math.random is pseudo-random and predictable from prior values. Web Crypto is cryptographically secure and unpredictable. For lottery / contest / password use, only the latter is acceptable.
Can I reproduce a specific result? No — there's no seed. Record the output if you need proof of a draw.
Can the generator pick a random card from a deck? Yes — use the "from a list" mode with 52 cards pasted. Or pick a number 1-52 and map manually.
What's the largest range supported? Up to 2³² (4.29 billion) via 32-bit values; up to ~9 × 10¹⁵ via 64-bit BigInt mode for very large ranges.
Can I generate negative numbers? Yes — set min to a negative integer (e.g., -100 to 100 generates from -100 through 100 inclusive).
Does the "sorted" toggle change the randomness? No. Sorting just rearranges the output; each underlying draw is still independent and uniform. Sorted output is convenient for lottery-style displays.
How do I avoid duplicates? Toggle "no duplicates" on. The tool draws-and-rejects internally until N unique values are collected.
Is it suitable for cryptographic key generation? The underlying entropy source is suitable, yes. For actual keys, use a dedicated crypto library (Web Crypto's `subtle.generateKey`) which handles key formats correctly. This tool generates raw integers, not formatted keys.
What about random decimals? Decimal mode supports any range with chosen decimal places. Internally uses uniform integer draws scaled to the decimal range.
Why does my count of "1s" not exactly match my count of "6s" in 100 dice rolls? True randomness has variance. In 100 rolls of a fair die, the expected count per face is 16.67, but you'd typically see anywhere from 10 to 25 for each face. That's normal.
Can I use this for a legally-binding lottery draw? Some jurisdictions require certified RNG for state-licensed lotteries (state-approved hardware RNGs). For personal raffles, contests, A/B tests, internal sampling, this tool is sufficient.