Random Number Generator

Generate one or more random whole numbers within a range — with or without duplicates.

Duplicates
Sort order
42, 87, 3, 15, 61 Copied ✓
AdvertisementAd slot #1 · below the result

What it does

Pick one or many whole numbers at random, between any minimum and maximum you set. Turn duplicates off when you need every draw to be distinct — for a raffle, a rota, or a random sample — and sort the result ascending or descending if you would like to read it in order. Everything happens in your browser; nothing is uploaded or stored.

How it works

Each draw asks the browser's cryptographically strong generator, crypto.getRandomValues, for a random 32-bit integer. The tool then maps that integer into your chosen range [min, max] using rejection sampling: any raw value that would skew the range gets discarded and re-drawn, so every whole number between min and max comes out equally often. The naive shortcut — rand % span — introduces a subtle bias called the "modulo bias", and we avoid it.

When you switch off duplicates, the tool builds the full list [min, min+1, …, max] once and shuffles the first count entries with a Fisher–Yates swap. That guarantees distinct draws, and it means asking for the whole range gives you a random permutation of it.

Range
span = max − min + 1

Worked example

With the seeded settings — 5 numbers between 1 and 100, duplicates allowed, unsorted — each press of Regenerate returns a fresh list of 5 whole numbers, every one somewhere in a span of 100 values. Because duplicates are permitted, the same number can appear more than once by chance; the more numbers you draw from a small range, the more likely that becomes.

Switch duplicates off and ask for six numbers from 1–6 sorted ascending, and you get a random permutation of the die faces — a shuffled 1 2 3 4 5 6 in some order. Push it further — ask for ten distinct numbers from a range of five — and the tool refuses with a clear message rather than looping forever: there are only five distinct values to choose from.

Common uses

  • Raffles and prize draws — number your entries and pick winners with duplicates off so nobody wins twice.
  • Random sampling — audit a subset of rows, tickets or records without cherry-picking.
  • Test data — seed a spreadsheet or a mock API with plausible whole numbers in a chosen range.
  • Making a decision — flip a virtual coin (1–2), roll a die (1–6), or split a group into teams.
  • Classroom activities — pick a student number, choose a page, or set an impromptu maths starter.

Frequently asked

Is it truly random?

It is as random as your browser can manage. crypto.getRandomValues is a cryptographically secure pseudo-random generator, seeded by the operating system's entropy pool — the same source of randomness used to generate encryption keys. For a raffle, a game or a sample it is indistinguishable from “true” randomness.

Why don't you use Math.random?

Math.random is fast but its output is predictable to anyone who can observe a few results, and older engines used generators with statistical flaws. crypto.getRandomValues costs almost nothing extra and is safe by default, so we use it for every draw.

What's the biggest range I can pick?

The tool works safely across the full range of JavaScript's exact integers, and lets you generate up to 1,000 numbers at a time.

Can I get negative numbers?

Yes — set the minimum below zero. A range of −10 to 10 draws from twenty-one whole numbers including zero.

What if I ask for more distinct numbers than the range allows?

The tool won't spin forever. It checks up front that your count fits when duplicates are off, and shows a clear message asking you to widen the range or allow duplicates.

See how we build and verify our tools.

AdvertisementAd slot #2 · after the explainer