We use cookies

We use cookies and similar technologies to enhance your browsing experience, analyze site traffic, and personalize content and ads. By clicking "Accept", you consent to our use of cookies. Learn more in our Privacy Policy.

Free · in your browser · no signup

Random Number Generator

Generate one or many random whole numbers between any min and max, using your browser's secure randomness — no bias, no signup.

Min
Max
How many

A Random Number Generator produces integers inside a range you choose, for example 1 to 100 or 0 to 4,294,967,295. This one generates each number using your browser's cryptographic random source rather than a seeded pseudo-random function, and it rejects values that would skew the distribution, so every integer in the range is equally likely. You set the minimum, maximum, and how many numbers you want, and it returns the result instantly.

It runs entirely in your browser. Nothing is sent to a server, no account is required, and the numbers are generated on your device, which matters when you are drawing winners, picking samples, or generating values you do not want logged anywhere. Use it for dice rolls, raffle draws, test data, A/B bucket assignment, random sampling, or any time you need numbers you can trust to be fair.

How it works

You give it three inputs: the minimum (inclusive), the maximum (inclusive), and the count of numbers to generate. It then draws from your browser's cryptographic random source and maps each draw into your range without bias.

Key behaviour:

  • Inclusive bounds — both ends are reachable. A range of 1 to 6 can return 1 or 6.
  • Crypto-backed randomness — values come from the operating system's entropy via the browser, not a fixed seed, so the output is not predictable or reproducible.
  • No modulo bias — naive code does random % rangeSize, which makes some numbers slightly more frequent. This tool discards out-of-range draws and re-rolls, keeping every value equally likely.
  • Optional uniqueness — generate distinct numbers (like a lottery draw) or allow repeats (like rolling dice many times).

Because it is client-side, generation is instant and works offline once the page has loaded.

A worked example

Say you are running a giveaway with 4,200 entries numbered 1 through 4200, and you need to pick 3 distinct winners.

Set:

  • Minimum: 1
  • Maximum: 4200
  • Count: 3
  • Unique: on

A possible result:

2871
149
3380

Each entry had exactly a 3-in-4200 chance of being drawn, and no entry could win twice because uniqueness was enabled. If you wanted dice instead, set min 1, max 6, count 5, uniqueness off, and you might get 4, 4, 1, 6, 2 — repeats are expected there.

The equivalent unbiased logic in JavaScript looks like this:

function randInt(min, max) {
  const range = max - min + 1;
  const maxValid = Math.floor(0xFFFFFFFF / range) * range;
  let x;
  do {
    x = crypto.getRandomValues(new Uint32Array(1))[0];
  } while (x >= maxValid); // reject to avoid modulo bias
  return min + (x % range);
}

Common use cases

  • Giveaways and raffles — pick winners by entry number, with uniqueness on so nobody wins twice.
  • Dice and games — simulate dice, card positions, or turn order with repeats allowed.
  • Test and seed data — generate IDs, quantities, ages, or prices for fixtures and demos.
  • Random sampling — select rows or records to audit or QA-check from a numbered set.
  • A/B and bucketing — assign users or items to groups (0 or 1, or 0 to 9 for ten buckets).
  • Decision making — break ties, assign chores, or choose between numbered options fairly.
  • Passwords and PINs — generate numeric codes when you need digits drawn from a trustworthy source.

For anything where fairness or auditability matters, the combination of a cryptographic source and on-device generation is the point: you can show the draw happened in front of you, and there is no server log to question.

Tips and gotchas

  • Unique count cannot exceed range size. If you ask for 10 distinct numbers between 1 and 5, that is impossible — there are only 5 values. Widen the range or turn uniqueness off.
  • Inclusive both ends. A range of 0 to 9 yields ten possible values, not nine. To pick an array index, use min 0 and max length - 1.
  • Order is also random. With uniqueness on, the results are not sorted; the sequence itself is shuffled, which is usually what you want for draw order.
  • Not seedable. Because the source is cryptographic, you cannot reproduce a past result by re-entering the same inputs. If you need repeatable output for a test, that is a different (seeded) requirement this tool does not serve.
  • Large counts are fine but copy the output before navigating away — results are not stored anywhere after you leave the page.

Why modulo bias matters

The fast, wrong way to squeeze a random 32-bit number into a smaller range is value % rangeSize. The problem: 2^32 is rarely an exact multiple of your range. Suppose your raw source returns 0 to 99 and you want 0 to 6 (7 values). 100 / 7 = 14 with a remainder of 2, so the values 0 and 1 each get 15 of the 100 source outcomes while 2 through 6 get only 14. The low numbers come up slightly more often.

The fix is rejection sampling: define the largest multiple of rangeSize that fits in the source space, and throw away any draw at or above it before taking the modulo. That removes the leftover that caused the skew. The cost is occasionally re-rolling, but for any sane range the re-roll rate is tiny and the distribution becomes exactly uniform. This is why a Math.random()-and-modulo snippet is fine for a casual dice roll but not for a fair raffle or a security-sensitive draw.

Crypto random vs Math.random

Math.random() is a pseudo-random generator: a deterministic algorithm with internal state that produces a sequence which only looks random. It is fast and fine for animations, jitter, or non-critical shuffles, but its output can be statistically weak and, in principle, predictable once enough values are observed.

This tool uses the browser's cryptographically secure generator (the crypto.getRandomValues family), which is seeded from the operating system's entropy pool. Practically, that means:

  • The output is unpredictable, even to someone who has seen previous results.
  • It is suitable for draws where someone has an incentive to game the outcome.
  • It is the right default whenever the numbers carry real weight — winners, codes, samples that must be defensible.

The trade-off is that it is not reproducible. For fairness that is a feature, not a limitation.

Tips

  • For a fair raffle, number every entry from 1 to N and draw with uniqueness on so no entry can win twice.
  • To pick a random array element, set min to 0 and max to length minus 1 — both bounds are inclusive.
  • Turn uniqueness off for dice, simulations, or anything where repeats are realistic and expected.
  • If a unique draw fails, your requested count is larger than the number of values in the range — widen the range.
  • Copy results before you leave the page; nothing is saved, so a refresh starts a fresh draw.
  • Need a reproducible sequence for tests? This tool is intentionally non-seedable; use a seeded generator in your code instead.

How to use Random Number Generator

  1. 1Set the Min and Max range.
  2. 2Choose how many numbers you want.
  3. 3Click Generate to produce them.
  4. 4Copy all the results — they're generated locally and never uploaded.

Frequently asked questions

Is the random number generator truly random?

It uses your browser's cryptographically secure random source, which is seeded from operating-system entropy. That makes the output unpredictable and statistically uniform, which is as close to true randomness as software gets on a normal device.

Are the minimum and maximum inclusive?

Yes. Both ends are reachable, so a range of 1 to 6 can return 1 or 6, and a range of 0 to 9 has exactly ten possible values.

How do I generate numbers with no duplicates?

Turn on the uniqueness option. The tool then returns distinct values only, which is what you want for raffles and lottery-style draws. The requested count must not exceed the number of values in your range.

What is modulo bias and does this tool avoid it?

Modulo bias happens when naive code maps a large random value into a smaller range with the % operator, making some numbers slightly more frequent. This tool uses rejection sampling to discard skewing values, so every number in the range is equally likely.

Can I reproduce the same numbers again with the same inputs?

No. Because the source is cryptographic rather than seeded, identical inputs produce different output each time. If you need a repeatable sequence for testing, use a seeded generator in your own code.

Does anything I generate get sent to a server?

No. The numbers are generated in your browser on your device. Nothing is uploaded or logged, which is why it is suitable for draws and codes you want to keep private.

Does it work offline?

Yes. Once the page has loaded, generation runs entirely on your device, so it keeps working without a network connection.

What is the largest range I can use?

You can generate across the full unsigned 32-bit range (0 to 4,294,967,295). For most uses — dice, raffles, sampling, PINs — your range will be far smaller, and any of those work instantly.

← All toolsRead our guides →