Random Number Generator
This random number generator returns whole numbers from an interval you choose. Set a Min and a Max, set how many numbers you want with Count (1 to 10,000), then press one button for a single value or a batch. Batch results come out as a comma-separated list and download as a CSV file, and two self-tests are built in — a uniformity test and a performance test — so you can check the source instead of taking it on trust. Every value is drawn from window.crypto by rejection sampling; Math.random() is never used.
Not tested yet
Not tested yet
What This Random Number Generator Does
Strip away the buttons and the whole job is one line of arithmetic: return an integer uniformly at random from a closed interval, meaning both Min and Max are included and every value in between is equally likely. That makes it a random number picker first — the plain “pick a random number” case — and the same engine answers to the other names people arrive with: a random integer generator for test data, a random digit generator when the interval is 0 to 9, and a randomizer number for the tie-break or the prize draw that just needs one value.
- One draw or a batch — one click gives a single number; the batch button fills the results box with Count values joined by a comma and a space, up to 10,000 per click.
- CSV export — the export button downloads
random_numbers_{min}-{max}_{count}.csv, one column namedvaluewith one number per row, ready to open in Excel, Sheets or pandas. - Two self-tests — a chi-square uniformity check (10,000 samples) and a performance check (10,000 draws must finish in under 100 ms), both reported in the tool itself.
- Cryptographically secure source — values come from
window.crypto.getRandomValuesthrough rejection sampling, so the distribution is uniform with no modulo bias. - Nothing leaves the browser — the whole tool is front-end JavaScript: no upload, no account, no server round trip, so the numbers are generated on your own device.
Two honest limits are worth stating up front, because they decide whether this page is the right tool. It is not a random number wheel or a spinning picker: there is no animation and no wheel, only the draw and the result. And it draws with replacement, so a batch may repeat a value — there is no repeat guard and no shuffle. For a lottery-style pick or a raffle where every number must be distinct, read the FAQ on repeats first; for everything else — sampling, dice, classroom exercises, mock data — independence is exactly what you want.
Formulas and Conventions
One formula drives the draw and four more describe the checks you can run on it. The symbols below are the ones used on this page.
| Symbol | Meaning | Definition used here |
|---|---|---|
| Min | lower bound of the interval | the value you type; included in the draw |
| Max | upper bound of the interval | the value you type; included in the draw and required to be ≥ Min |
| n | how many whole numbers the interval holds | n = Max − Min + 1 |
| X | one draw | an integer, every value in the interval equally likely |
| N | samples per self-test | 10,000, fixed by the tool |
| k | bins in the uniformity test | 10, because that test always samples 1 to 10 |
| Oi | observed count in bin i | how many of the 10,000 samples landed on bin i |
| Ei | expected count in bin i | N ÷ k = 1,000 per bin |
| χ² | chi-square statistic | compared with the critical value 16.919 (9 degrees of freedom, 5% level) |
| t | time for a 10,000-draw batch | the performance test passes when t is under 100 ms |
The interval. The count of possible values and the chance of each one follow directly from the bounds:
\[ n = \text{Max} – \text{Min} + 1, \qquad P(X = x) = \frac{1}{n} \quad \text{for every integer } x \in [\text{Min}, \text{Max}] \]
A long run centers on the midpoint of the interval, which is a useful sanity check on any batch you draw:
\[ E[X] = \frac{\text{Min} + \text{Max}}{2} \]
Why rejection sampling. A 32-bit crypto value is a number from 0 to 4,294,967,295, and that range is not a clean multiple of every interval size. Scaling or taking a remainder would give the lowest values a slightly higher chance, which is the modulo bias. The tool instead computes an acceptance limit and redraws anything above it, so every value has exactly the same probability:
\[ \text{limit} = \left\lfloor \frac{2^{32}}{n} \right\rfloor \cdot n – 1, \qquad \text{result} = \text{Min} + (x \bmod n) \ \text{ if } x \le \text{limit, otherwise redraw} \]
Why not Math.random(). Math.random() is a fast pseudo-random generator meant for animation and games. It is seeded once from a small internal state and then advanced by a deterministic algorithm, so its output is statistically plausible but predictable: an observer who sees enough consecutive values can reconstruct the state and compute the next ones, which is why MDN warns against using it for anything security-related. This tool uses the Web Crypto API instead — entropy from the operating system, designed to be unpredictable even to someone who knows the algorithm and has already seen earlier outputs. The difference matters for password-adjacent values, coupon codes and any draw where someone could profit from guessing.
Precision and boundaries. Every value that comes out is a whole number, so nothing is rounded to two decimals and there is no display cut-off to reason about; a decimal such as 1.5 is rejected outright rather than rounded to 1 or 2. Min and Max must both be integers with Max ≥ Min, and the interval may hold at most 4,294,967,296 values — the width of the 32-bit sampler; the values themselves are not capped, only the distance between them. The batch Count must be a positive number from 1 to 10000. Values may be negative, so an interval such as Min −50 to Max 50 is legal. Nothing on this page is a measurement — a draw from 1 to 100 is the same set of whole numbers whether you would have written your height as 5 ft 9 in or 175 cm, because the tool returns counts, not lengths or weights.
The two self-tests. The uniformity test ignores your inputs: it always draws 10,000 samples between 1 and 10, counts how many land in each of the 10 bins, and compares the statistic with the critical value:
\[ \chi^{2} = \sum_{i=1}^{k} \frac{(O_i – E_i)^{2}}{E_i}, \qquad E_i = \frac{N}{k} = \frac{10000}{10} = 1000 \]
The performance test does use your current Min and Max: it draws 10,000 numbers and times the batch. Both tests print a fixed-format line, Chi-Square: … (Critical: 16.919). Result: PASS and Time: …ms. Result: PASS, where the ellipsis is the only part that changes between runs.
How to Use the Random Number Generator
- Type Min and Max. Both must be whole numbers, and Max must be at least Min; negative bounds are allowed. A rejected bound is flagged where you typed it with “Invalid Min value” or “Invalid Max value”.
- Set Count — how many numbers you want in one batch, from 1 to 10,000. A bad count is flagged as “Invalid Count (1-10000)”.
- Draw. One button returns a single number in the results box; the batch button returns all of them separated by a comma and a space. Nothing is stored, so the number you see is the number you got.
- Export if you need a file. The export button downloads
random_numbers_{min}-{max}_{count}.csvwith one column namedvalueand one number per row. It draws a fresh batch rather than dumping the list on screen, so the file can differ from what you just saw — the file name encodes Min, Max and Count, so two exports with the same settings share a name. - Optional: press the two self-test buttons before you rely on the numbers. They are the quickest way to convince yourself that the source is uniform and fast enough for a 10,000-value batch.
- If any field fails validation, the message appears with that field and the results box shows “Please fix input errors” instead of a number — no silent fallback to a default range.
Intervals that cover most visits, with the Min and Max to type:
| What you want | Min | Max | Notes |
|---|---|---|---|
| Roll a die | 1 | 6 | each face has a 1 in 6 chance |
| Flip a coin | 1 | 2 | read 1 as heads and 2 as tails |
| Draw a card | 1 | 52 | no repeat guard, so a batch can return the same card twice |
| Pick a student or a seat | 1 | 30 | adjust Max to the size of your class |
| Pick a number 1 to 100 | 1 | 100 | the classic percentage-style draw |
| Four-digit code | 1000 | 9999 | every draw has exactly four digits |
| Six-digit code | 100000 | 999999 | every draw has exactly six digits |
| Eight-digit code (the default) | 10000000 | 99999999 | the interval the tool opens with |
The plugin exposes the same three settings as shortcode attributes, so a page can open with them already filled in: [app_random_number min="1" max="100" count="20"]. The defaults are min 10000000, max 99999999 and count 10, which is why the fields start as an eight-digit interval.
Worked Examples
The drawn numbers themselves cannot be quoted — a fixed value would defeat the point — so each example below describes exactly what the page returns for one of the three configurations in this page’s example set, including the interval arithmetic, the file name and the wording of the self-test lines. Every number shown is derived from the formulas above, not read off a screenshot.
| Example | Min | Max | Count | Values in the interval | Chance per value | CSV file name |
|---|---|---|---|---|---|---|
| 1 | 1 | 10 | 5 | 10 | 1 ÷ 10 = 10% | random_numbers_1-10_5.csv |
| 2 | 1 | 100 | 10 | 100 | 1 ÷ 100 = 1% | random_numbers_1-100_10.csv |
| 3 | 10000000 | 99999999 | 3 | 90000000 | 1 ÷ 90000000 | random_numbers_10000000-99999999_3.csv |
Example 1 — five numbers from 1 to 10
Set Min 1, Max 10 and Count 5. The interval holds n = 10 − 1 + 1 = 10 whole numbers, so each one has a 1 ÷ 10 = 10% chance on every draw, and the batch button fills the results box with five values from 1 to 10 in the order they were drawn. Repeats are possible: the chance that all five happen to be different is (10 × 9 × 8 × 7 × 6) ÷ 10⁵ = 30.24%, so roughly seven batches out of ten contain at least one duplicate. The average of a long run sits at (1 + 10) ÷ 2 = 5.5, which is why a batch that looks “too low” is usually just a short run. Export gives random_numbers_1-10_5.csv.
Example 2 — ten numbers from 1 to 100
Min 1, Max 100 and Count 10 is the classic random number generator 1-100 setup, and it is also how people generate random numbers for a percentage-style pick: n = 100, each value has exactly a 1% chance, and the long-run average is (1 + 100) ÷ 2 = 50.5. With ten draws from a hundred values the batch is the answer to “pick a number between 1 and 100” ten times over — useful for classroom exercises, sampling a top-100 list or filling a column of mock data. Duplicates across ten draws are uncommon but not rare, and the CSV lands as random_numbers_1-100_10.csv.
Example 3 — three draws from the default eight-digit interval
Leave the page as it loads: Min 10000000, Max 99999999, Count 3. That is the plugin’s default interval, and it holds n = 99999999 − 10000000 + 1 = 90,000,000 whole numbers, so every draw is one of the 90 million eight-digit values and the chance of any particular one is 1 ÷ 90,000,000. The long-run average would be (10000000 + 99999999) ÷ 2 = 54,999,999.5 — and the honest reading is that three draws tell you nothing about it: three values from a 90-million-wide interval will look scattered, and they should. What you can rely on is that each draw is independent and that no eight-digit value is favored over another. Export gives random_numbers_10000000-99999999_3.csv.
What the self-tests print
Run the uniformity test and the tool draws its own 10,000 samples between 1 and 10, so 1,000 per bin is the expected count and the line reads Chi-Square: … (Critical: 16.919). Result: PASS. Read it honestly: 16.919 is the 5% critical value for 9 degrees of freedom, so a perfectly fair source still fails that check about one run in twenty, and a FAIL is a prompt to run it again, not a verdict. The performance test draws 10,000 numbers from your current Min and Max and prints Time: …ms. Result: PASS, with PASS requiring the batch to finish in under 100 ms — a bar that any modern device clears easily, because the whole batch is one 32-bit crypto read per number plus the occasional redraw when a sample lands in the rejected tail.
Random Number Generator FAQ
Are these numbers truly random?
No generator on a web page is “truly random” in the physical sense, and this one does not claim to be; it is cryptographically secure and uniformly distributed, which is the property that matters in practice. Values come from window.crypto.getRandomValues, so they are unpredictable from earlier outputs, and rejection sampling makes every value in the interval equally likely. For a raffle, a sample or a set of test numbers, that is stronger than what a spreadsheet or Math.random() gives you.
How is this different from Math.random()?
Math.random() is a fast pseudo-random generator built for animation and games. Its values look random, but they come from a deterministic algorithm whose internal state can be reconstructed from enough consecutive outputs, at which point the following values can be predicted — which is why it is not recommended for anything security-related. This tool calls the Web Crypto API, seeded by operating-system entropy, and it never falls back to Math.random(): even the shared fallback path inside the plugin is rejection sampling on the crypto source.
Can the same number come up twice in one batch?
Yes. Every draw is independent, so duplicates are normal rather than a bug — there is no repeat guard and no shuffle in this tool. Five draws from 1 to 10 are all different only about 30% of the time, so most batches of that size contain a repeat. If you need distinct values, draw more numbers than you need and de-duplicate the CSV in a spreadsheet, or draw one at a time and skip a value you have already used.
What are the limits on Min, Max and Count?
Min and Max must be whole numbers with Max at least as large as Min, the interval can span at most 4,294,967,296 values, and Count must be a positive number from 1 to 10000. Decimals are rejected rather than rounded, so 1.5 produces “Invalid Min value” or “Invalid Max value”, a Max below Min produces “Invalid Max value”, and a count outside the range produces “Invalid Count (1-10000)”. Negative bounds are fine; only the width of the interval is capped, not the size of the values.
How do I export the numbers to a CSV file?
Press the export button and the browser downloads a file named random_numbers_{min}-{max}_{count}.csv — for ten numbers between 1 and 100 that is random_numbers_1-100_10.csv. The file contains one header cell, value, and one number per row, so it opens cleanly in Excel, Google Sheets or a script. Note that the export draws a fresh batch: it does not necessarily match the list currently shown in the results box.
What do the two self-tests actually prove?
They are spot checks on the source, not a proof of every statistical property. The uniformity test draws 10,000 samples from 1 to 10, compares the chi-square statistic against 1,000 expected per bin and prints Chi-Square: … (Critical: 16.919). Result: PASS. Because 16.919 is the 5% critical value for 9 degrees of freedom, a fair generator still fails about one run in twenty, so treat a FAIL as “run it again”, not as proof of a broken source. The performance test draws 10,000 numbers from your current Min and Max and prints Time: …ms. Result: PASS, where PASS means the batch finished in under 100 ms.
Can I use it as a lottery number generator or for a raffle?
Yes for the draw, with one caveat you have to plan around: the tool draws with replacement, so it will not hand you six distinct lottery balls. A lottery-style pick works as Min 1, Max 49 (or whatever your game uses) and then a look for duplicates in the batch, or better, one draw at a time with a re-draw whenever a number repeats. A raffle is simpler: number the tickets 1 to N, set Max to N and draw once — one draw, one winner, with every ticket equally likely.
Can I get the same numbers again later — is there a seed?
No. There is no seed and no history, so a batch cannot be replayed, and that is deliberate: an unpredictable sequence is the point. If you need reproducible values for a test, draw them once and keep the CSV — the file is the record. If you need a reproducible sequence in code, use a seeded pseudo-random generator in your language or database, and reserve this tool for the draws that must not be predictable.
Related Tools
Three pages sit next to this one. When the value you need is text rather than a number — tokens, IDs, test strings — the random string generator draws from character sets with the same crypto source and adds a copy button. When the secret has to be something you actually log in with, the password generator is the specialist: length up to 256 characters, symbol and exclusion options, a strength meter and a copy button. And when the number you want is a share of something rather than a raw draw — 15 percent of 200, a tip, a discount — the percentage calculator is the right page.

