Skip to content

Random Number Generator

Embed this tool

Add the Random Number Generator to your own site, class page or blog: paste this code where it should appear. It runs in the visitor’s browser like this page does.

Random Number Generator

Generate one or many random numbers in any range, with options for integers vs decimals, with or without repeats, and sorted or unsorted output. Uses the browser's cryptographic random source, so the numbers are genuinely unpredictable — not the seeded pseudo-random output most generators produce.

Why Quality of Randomness Matters

Not all randomness is equal. Math.random() in JavaScript is a pseudo-random number generator: given the same internal state, it produces the same sequence. That's fine for shuffling a music playlist or picking a placeholder colour, but unacceptable for anything where predictability is a problem — password generation, security tokens, sample selection in research, drawing winners from a public contest.

crypto.getRandomValues() is the right primitive when randomness has to be unpredictable. It pulls from the operating system's entropy pool — keyboard timings, network packet jitter, hardware noise — which means the next number can't be derived from the previous one. This generator uses crypto.getRandomValues() for every output, even the playful uses, so the same code path serves both casual and serious work.

How It Works

For integers, the tool takes 53 random bits from crypto.getRandomValues() (two 32-bit draws) and uses rejection sampling: a draw that would make some numbers more likely than others is thrown away and redrawn, so every integer in your range has exactly the same chance, for ranges up to 2⁵³ (about 9 quadrillion). Decimals are drawn from the grid of steps between min and max (0.00, 0.01 … 1.00 for two places), so every step, including both ends, is equally likely. For no repeats it uses Floyd’s algorithm, which picks K distinct numbers without listing the whole range, then shuffles them.

Need a single secure token instead of a number? The password generator and UUID generator use the same crypto primitive for token-shaped output rather than numbers.

Common Use Cases

Picking a winner from a numbered entry list — generate one integer in [1, N]. Selecting a random sample of rows from a CSV — generate K unique integers in the row-count range, no repeats. Generating test data that needs to look plausibly random rather than sequential. Picking a random colour seed for a generative design. Drawing random angles for a parametric animation. Rolling dice for tabletop games when you don't have physical dice handy.

Worked example: how the numbers are drawn

On October 12, 2026 we read the tool’s code and worked through its behaviour, then rebuilt the three weak spots the same day. Before the fix, each draw took one 32-bit value, divided by 2³² and scaled it to your range; unique mode listed every number in the range first; decimals were a rounded continuous value. The table shows the old behaviour; the notes below it show the re-test.

UseWhat happensEffect
Dice, 1–62³² mod 6 = 4 extra casesbias ≈ 1 in a billion: irrelevant
Raffle, 1–10,000bias ≈ 2 in a millionirrelevant for draws
1–10,000,000,0002³² ≈ 4.29 billion possible outputs57% of the integers can never come up
Unique, 1–20,000,000builds every number in memory first≈380 MB and 1.2 s in Node before the first pick
Decimals, 0–1, 2 placesrandom float rounded with toFixed0.00 and 1.00 come up half as often as other values

Sources

Checked on .

Frequently Asked Questions

How random are the numbers?+
Each draw uses crypto.getRandomValues(), the browser's cryptographically secure generator, so results cannot be predicted from earlier ones. Mapping to your range adds a tiny bias (about 1 in a billion for dice) and limits even coverage to ranges below about 4.29 billion.
What's the maximum range?+
Min and max can be any whole numbers within ±9,007,199,254,740,991 (2⁵³ − 1, the largest integer JavaScript stores exactly), and every integer in the range is equally likely. You can generate up to 10,000 numbers at once, with or without repeats; unique mode no longer needs a small range.
Can I generate decimal numbers?+
Yes. Toggle decimals mode and choose how many decimal places (1-10). Decimal mode always allows duplicates since floating-point numbers have effectively infinite range.
Can the same number appear twice?+
By default yes. Toggle 'unique only' to ensure every generated number is different. Useful for lottery draws, raffle tickets, or picking distinct items.
Is the random number generator cryptographically secure?+
The source is: crypto.getRandomValues is a cryptographically secure generator. The scaling to your range is fine for draws, games and sampling but is not a vetted key-generation method; for tokens and keys, use the password or UUID generators, which take the bytes directly.
Can I generate without replacement?+
Yes — the "no duplicates" toggle ensures each number in a batch is unique. Useful for lottery picks, randomised draws, and shuffling sequences.
What range can I generate?+
Any range that fits in normal JavaScript numbers, but even coverage stops at about 4.29 billion values: a single draw is a 32-bit number, so in wider ranges many integers cannot come up. There is no BigInt mode. For unique numbers, keep the range small (well under a million), because the whole range is listed in memory first.
How is this different from Math.random()?+
Math.random() is NOT cryptographically secure — its output is predictable from prior outputs. crypto.getRandomValues is secure but slightly slower. The tool always uses the secure variant; the difference is imperceptible at human scales.

📖 Learn More

Related Guide Random Number Generator Guide →

Built by Derek Giordano · Part of Ultimate Design Tools

Privacy Policy · Terms of Service