Skip to content

Random Number Generator

Set a min, max, and how many numbers you want, with or without duplicates, and get genuinely uniform random integers — generated with crypto.getRandomValues and rejection sampling to eliminate modulo bias, the same approach this site's Password Generator uses, not the predictable Math.random most "random number generator" tools reach for.

  • Cryptographically random, not Math.random
  • Rejection sampling eliminates modulo bias
  • Optional duplicates, up to 10,000 numbers at once
  • Runs fully client-side

Generator

Generated locally, nothing uploaded

How to generate random numbers

  1. 01

    Set the min and max

    The inclusive range the numbers should fall within.

  2. 02

    Set how many you want

    Choose whether duplicates are allowed.

  3. 03

    Generate

    Each click produces a fresh set of numbers.

Why this does not use Math.random#

JavaScript's Math.random is a fast pseudorandom generator with a predictable internal algorithm — good enough for a visual flourish, not for anything where genuine unpredictability matters, like a raffle drawing, a fair random assignment, or picking a number nobody could have anticipated. crypto.getRandomValues draws from the operating system's cryptographically secure random source, the same category used to generate encryption keys — the actual bar for something meant to be truly unpredictable, not just statistically random-looking.

The subtler bug this avoids: modulo bias#

A common but flawed shortcut for "random number in a range" takes a random 32-bit integer and computes it modulo the range size — which is nearly right but not exact, because 2^32 is rarely a clean multiple of the requested range. That mismatch means the low end of the range gets picked very slightly more often than the high end, a bias too small to notice by eye but real and measurable over enough draws. This tool avoids it with rejection sampling: it discards any raw value that falls in the small leftover portion that would cause the bias, and draws again, guaranteeing every number in the range is exactly equally likely.

Why "no duplicates" has a hard limit#

Asking for 10 unique numbers from a range of only 5 possible values is mathematically impossible — there simply are not enough distinct numbers to satisfy the request. This tool checks that up front and explains clearly why, rather than either hanging while endlessly failing to find a new unique value or silently returning fewer numbers than asked for.

Frequently asked questions

Why not just use Math.random like most random number tools?

Because Math.random is a fast, predictable pseudorandom generator — fine for a visual effect, not for something meant to be genuinely unpredictable. This tool uses crypto.getRandomValues, the same cryptographically secure source used to generate encryption keys.

What is rejection sampling and why does it matter here?

A naive "random value modulo range size" approach is very slightly biased toward lower numbers, because the range rarely divides evenly into 2^32. This tool discards values that would cause that bias and draws again, so every number in the range is exactly equally likely.

Why does "no duplicates" sometimes give an error?

Because asking for more unique numbers than the range actually contains is mathematically impossible — the tool checks for that up front instead of silently returning fewer numbers than requested.

Is my data sent anywhere?

No. Numbers are generated entirely in your browser.

Developers

UUID Generator

Generate cryptographically random UUID v4 or time-ordered UUID v7, in bulk.

Developers

Base64 Encoder & Decoder

Encode and decode Base64 with correct UTF-8 handling, including the URL-safe alphabet.

Developers

ULID Generator

Generate ULIDs — sortable by creation time like UUID v7, but Crockford Base32 instead of hex.