N
NJHTools

Random Number Generator

Generate cryptographically random numbers or pick random items from a list. Uses crypto.getRandomValues() — cryptographically secure, not Math.random().

Optional. Commas between values, dashes for ranges.

Tip: press Space or Enter to generate again.

How is this random?

Every number comes from crypto.getRandomValues(), the browser’s Web Crypto API. It is a cryptographically secure random number generator (CSPRNG) that your browser seeds from the operating system’s entropy pool — unpredictable timing noise from hardware, and on most modern CPUs a dedicated hardware random number instruction. Seeing earlier results tells you nothing about the next one. Nothing is sent to a server.

No modulo bias: rejection sampling

Random bytes have to be mapped onto your range. The naive way, byte % range, is subtly unfair: one byte has 256 possible values, so byte % 100lands on 0–55 three ways but on 56–99 only two ways, making the low numbers 50% more likely. This generator uses rejection sampling instead. It throws away any value above the largest exact multiple of the range (199 in that example) and draws again, so every whole number between Min and Max is exactly equally likely. Excluded numbers are removed before the draw, so the numbers that remain stay equally likely too.

Compared with Math.random()

Math.random()is a fast pseudo-random generator built for animations and simulations; in Chrome and Edge it is xorshift128+. Its internal state can be worked out from a handful of outputs, after which every future “random” number is predictable. That is fine for shuffling a playlist, but not for a raffle, a giveaway or anything where someone could gain by guessing the result.

Compared with random.org

random.org generates true random numbers from atmospheric noise picked up by radio receivers, and can record draws publicly. A CSPRNG seeded by your device is unpredictable for all practical purposes, works offline and keeps your numbers private. For classrooms, games and everyday giveaways, either is fair. If a draw must be independently verifiable, for example a regulated lottery, use an audited draw service.

Frequently Asked Questions

How do I generate a random number between 1 and 10?↓

Open https://www.njhouse.kr/tools/random-number, make sure 'Single number' is selected, set Min to 1 and Max to 10, then click Generate. The tool uses crypto.getRandomValues() so each number is cryptographically random.

Is this random number generator truly random?↓

For every practical purpose, yes. This generator uses the browser's Web Crypto API (crypto.getRandomValues()), a cryptographically secure generator seeded from your operating system's entropy sources — the same source used for encryption keys and password generation. Its output cannot be predicted, unlike Math.random(), whose internal state can be reconstructed from a few outputs.

Can I generate a list of unique random numbers?↓

Yes. Switch to the 'Multiple numbers' tab, set your Min, Max, and Count, then enable the 'No duplicates (unique)' toggle before clicking Generate. The tool uses a random shuffle to ensure all numbers are unique within the specified range.

Can I pick a random item from a list?↓

Yes. Switch to the 'Pick from list' tab, paste your items one per line (names, options, etc.), set how many to pick, and click Generate. Enable 'No duplicates' to ensure each item is picked at most once.

What is the difference between Math.random() and crypto.getRandomValues()?↓

Math.random() uses a pseudo-random number generator (PRNG) seeded by the browser — it is deterministic and not suitable for security applications. crypto.getRandomValues() uses the operating system's cryptographically secure entropy source, making it suitable for passwords, keys, and any application requiring true unpredictability. This tool always uses crypto.getRandomValues().

Does this random number generator have modulo bias?↓

No. Mapping random bytes onto a range with a plain remainder (%) makes some numbers more likely whenever the range does not divide evenly — for example, one byte (0–255) % 100 makes 0–55 appear 50% more often than 56–99. This tool uses rejection sampling instead: byte values above the largest exact multiple of your range are thrown away and redrawn, so every whole number in the range is exactly equally likely.

How does this compare to random.org?↓

random.org produces true random numbers from atmospheric noise captured by radio receivers, and can keep public records of draws. This tool uses crypto.getRandomValues(), a cryptographically secure generator seeded by your device's entropy, which is unpredictable for all practical purposes. It runs offline in your browser, so your numbers are never sent to a server. For everyday picks, games, classrooms and giveaways either is fine; use an audited draw service when a draw must be publicly verifiable.

Last updated: