Skip to content
Kalio
Generators

Random number generator

Generate random numbers in any range using cryptographic randomness, with options for no repeats and sorted output - for draws, sampling and testing.


Ready · runs on your device

Nothing is uploaded. This tool runs entirely inside your browser tab. Your files and figures stay on your device - we never receive them, so we cannot read, store or lose them.

How the numbers are drawn

Every value comes from crypto.getRandomValues, the browser’s cryptographically secure random number generator, seeded by the operating system.

Converting a raw 32-bit value into a number within your range is where most implementations quietly go wrong. The naive approach, value % range, produces a non-uniform distribution whenever the range does not divide 2³² evenly - some outcomes become slightly more likely than others.

This generator uses rejection sampling: it computes the largest multiple of the range that fits within 2³², discards any draw at or above that threshold, and tries again. The result is exactly uniform, at a cost of occasionally drawing twice.

With and without replacement

With replacement (the default) means every draw is independent and duplicates are possible. Ask for 6 numbers from 1–49 and you might get two 23s. This is the correct model for dice, coin flips and repeated independent trials.

Without replacement (“no repeats”) means each value can appear once, like drawing balls from a bag and not putting them back. This is the correct model for lottery draws, raffles and picking a sample of distinct items.

The distinction matters more than it seems. The chance of at least one duplicate when drawing 6 numbers from 1–49 with replacement is about 30% - far higher than intuition suggests, and the same birthday-paradox effect that surprises people about shared birthdays in a room of 23.

What it is used for

  • Draws and raffles. Assign each entrant a number, then draw without repeats.
  • Random sampling. Selecting rows for a quality audit or survey.
  • Simulation and testing. Generating test data or seeding scenarios.
  • Games. Dice, spinners and card positions - set the range to 1–6, 1–20 or 1–52.
  • Assignment. Splitting a group into teams, or deciding an order fairly.

The limits of a private generator

Everything here happens in your browser, which is exactly what makes it private - and exactly what makes it unauditable. Nobody, including us, can see the numbers. Equally, nobody can independently confirm you did not press regenerate until you liked the answer.

For a draw with real stakes, that matters. Regulated lotteries use hardware entropy sources, sealed procedures and independent observers, and the point is not better randomness - it is demonstrable randomness. If your draw needs to be defensible, run it publicly or use a service that publishes a verifiable seed.

On “true” randomness

Your operating system’s entropy pool draws on genuinely unpredictable physical sources: interrupt timing, hardware random number instructions on modern CPUs, and other jitter. Whether that is philosophically “true” randomness is a question for physicists. For every practical purpose - cryptographic and otherwise - it is unpredictable to anyone who does not already have control of your machine.

Common questions

Is this random enough for a prize draw?

The randomness itself is cryptographic quality - the same source used for encryption keys - and the sampling is provably unbiased. What it cannot give you is auditability - because everything happens privately in your browser, there is no record a third party could verify. For a regulated draw you need a witnessed or logged process, not just a good generator.

What is the difference between this and Math.random?

Math.random uses a fast non-cryptographic algorithm whose future output can be predicted from a modest number of past values. This tool uses crypto.getRandomValues, seeded from your operating system's entropy pool. For a game the difference is irrelevant; for anything where someone benefits from predicting the result, it is the whole ballgame.

How does the "no repeats" option work?

For ranges up to 10,000 values it builds the full list and shuffles it with Fisher–Yates, then takes as many as you asked for. For larger ranges it draws numbers and discards duplicates. Both give a uniform sample without replacement; the first is just faster when the range is small.

Can I use this to pick lottery numbers?

You can, and the numbers are genuinely random. It will not improve your odds - every combination is equally likely in a fair draw, whatever process picks it. The only practical argument for random selection is that it avoids popular patterns like birthdays, so if you did win you would be less likely to share the prize.

Last reviewed