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.
| Use | What happens | Effect |
|---|---|---|
| Dice, 1–6 | 2³² mod 6 = 4 extra cases | bias ≈ 1 in a billion: irrelevant |
| Raffle, 1–10,000 | bias ≈ 2 in a million | irrelevant for draws |
| 1–10,000,000,000 | 2³² ≈ 4.29 billion possible outputs | 57% of the integers can never come up |
| Unique, 1–20,000,000 | builds every number in memory first | ≈380 MB and 1.2 s in Node before the first pick |
| Decimals, 0–1, 2 places | random float rounded with toFixed | 0.00 and 1.00 come up half as often as other values |
- Fine for everyday ranges. The randomness comes from the operating system's secure generator, and for ranges up to millions the scaling bias is far too small to matter for games, raffles or sampling.
- Large ranges are covered evenly. Re-test in Node with the tool’s new functions: of 100,000 draws from 1 to 10,000,000,000, 57.2% were above 2³², matching the 57.1% expected; before, none could be. A chi-square test on 200,000 draws from 1–10 gave 3.8 (the 99% limit is 21.7).
- Unique mode works on any range. Five or ten distinct numbers from 1–20,000,000 now take about 10 ms and almost no memory (it used to build all 20 million numbers, about 380 MB). Asking for the whole range still returns a complete shuffled list.
- Decimal ends are no longer half as likely. In 505,000 draws of two-place decimals between 0 and 1, 0.00 came up 5,044 times, 0.50 4,924 times and 1.00 4,920 times, against about 5,000 expected for each of the 101 values.
Sources
Checked on .
Frequently Asked Questions
📖 Learn More
Related Guide Random Number Generator Guide →Built by Derek Giordano · Part of Ultimate Design Tools