Skip to content
Toolcroft

Random Number Generator

Random Generators

Generate integers or decimals with Web Crypto (never Math.random). Set range, precision, count, uniqueness, and sorting; unique draws respect grid capacity.

Integer mode uses whole numbers from ceil(Min) through floor(Max), inclusive.

Configure the options above and click Generate.

How to use this tool

  1. Set the range. Enter the minimum and maximum values. Integer mode rounds the bounds inward to whole numbers; for a standard d6 die, set min = 1 and max = 6.
  2. Choose decimal places. Set to 0 for integers. Set to 2 for values like 3.14. Up to 10 decimal places are supported.
  3. Set the count. Enter how many numbers to generate, from 1 to 10,000.
  4. Configure options and generate. Toggle duplicates and sorting as needed, then click Generate. Copy individual numbers or the full list.

How random numbers are generated

Every number on this page is produced by crypto.getRandomValues: the browser's built-in cryptographically secure random number generator. It is seeded by the operating system's entropy pool (hardware events, timing jitter, etc.), making it suitable for simulations, games, raffles, and anything requiring high-quality randomness.

Rejection sampling is used to eliminate modulo bias. Naïvely using randomValue % range slightly favors some outputs when range doesn't evenly divide the generator's output space. The rejection approach re-draws any value that would introduce bias, guaranteeing a perfectly flat distribution across the range.

Common use cases

  • Pick a random winner: assign each entrant a number, generate one random integer in that range.
  • Simulate a die roll: set min = 1, max = 6 (or 20 for a d20).
  • Sample items from a list: generate unique integers in [1, list length] with duplicates disabled.
  • Monte Carlo simulations: generate large batches of decimals in [0, 1] with high decimal precision.
  • Random lottery picks: generate unique integers in your lottery's range, sorted ascending.

Integer vs decimal mode

Set Decimal places to 0 for whole numbers. Any value from 1–10 switches to decimal mode. For example, min = 0, max = 1, decimals = 4 produces values like 0.3821: useful for probability sampling or random weights.

Integer mode rounds the entered bounds inward: the first eligible number is ceil(min) and the last is floor(max). A range from 1.5 to 2.5 therefore contains only the integer 2; a range from 1.5 to 1.8 contains no integer and produces a validation message. In decimal mode, eligible values use the selected decimal step and stay within the entered bounds. The endpoints appear only when they land on that grid.

Statistical distributions

This tool generates numbers from a uniform distribution: every value in the range is equally likely. Many real-world simulations require non-uniform distributions:

  • Normal (Gaussian) distribution: bell curve centered on a mean; used in Monte Carlo simulations, manufacturing tolerances, and statistical modeling. Not available here — use a statistics tool or the Box-Muller transform in your own code.
  • Exponential distribution: models time between random events (e.g., server request intervals).
  • Binomial distribution: models the number of successes in n independent trials.

Batch mode and unique numbers

The no duplicates option implements sampling without replacement: every eligible integer or decimal grid value can appear at most once. Before drawing, the tool counts the available values and reports the capacity if the requested Count is too large. For example, [1, 3] at one decimal place contains 21 values, so a unique request for 50 numbers is rejected instead of returning a shorter list. This is useful for lottery draws, random seat assignments, and sampling list positions when each item can only be selected once. With duplicates allowed (the default), each draw is independent (sampling with replacement).

Unique sampling shuffles only the requested part of the virtual range, so extra memory grows with Count rather than with the number of possible values. Very large bounds at high decimal precision cannot always be represented as distinct JavaScript numbers; the tool rejects those combinations with guidance to use smaller bounds or fewer decimal places. This keeps large ranges responsive while preserving distinct values and unbiased Web Crypto draws.

Frequently asked questions

Is this truly random?

Yes - all numbers are generated using the browser's Web Crypto API (`crypto.getRandomValues`), which is cryptographically strong. This is far better than `Math.random()`, which is a deterministic pseudo-random generator not suitable for security or high-quality randomness needs.

How do I generate a random number between 1 and 100?

Set Min to 1, Max to 100, Decimal places to 0, and Count to 1, then click Generate. The result will be a random integer from 1 to 100 inclusive. In integer mode, non-integer bounds are rounded inward: Min rounds up and Max rounds down.

What does "allow duplicates" mean?

When duplicates are allowed (the default), the same value can appear more than once in the output - each number is drawn independently. When duplicates are disabled, every number in the output is unique. The range must contain at least as many eligible integer or decimal values as the requested count; the generator checks that capacity before drawing.

How are non-integer bounds handled?

With Decimal places set to 0, the tool uses whole numbers from ceil(Min) through floor(Max), inclusive. For example, a range of 1.5 to 2.5 can return only 2, while 1.5 to 1.8 contains no whole number and needs a wider range or decimal places. With decimal mode, only values at the selected precision that fall inside the entered bounds are eligible.

What is rejection sampling?

The generator maps a 32-bit random integer to the requested range. Naïvely using modulo can slightly over-represent some values (modulo bias). Rejection sampling discards values that would cause this bias and re-draws, guaranteeing a perfectly uniform distribution.

Browse all random generators