Skip to content
gohacks.dev
Tooling

Random Number Generator

Generate random integers in a range with or without repeats, sorted or not, and roll dice in NdS+M notation, using the browser's cryptographically secure generator.

Free · No sign-up · Your inputs stay in your browser

Input

Generate random numbers

Output

Press Generate

Drawn from crypto.getRandomValues, the browser's cryptographically secure generator, with rejection sampling so every value in the range is equally likely; the common Math.floor(Math.random() * n) is neither secure nor, for large ranges, uniform. Good enough for giveaways and test data; a public lottery needs an auditable source.

Runs in this browser. Nothing you paste is sent to a server.

Math.random is not enough

Math.random is a fast, predictable generator meant for animations and simulations; its output can be reconstructed from a few samples. The common Math.floor(Math.random() * n) is also slightly biased for large n. For draws people might contest, such as giveaways, or for anything security-related, a CSPRNG with unbiased sampling is the right tool. The getRandomValues documentation describes the API.

Auditable draws

For a public lottery or a draw with stakes, a result nobody can verify after the fact is not enough. Publish the method in advance and use a verifiable source such as a public randomness beacon.

Share

Frequently asked questions

How do I pick random numbers without repeats?
Turn on No repeats. With a range smaller than the count requested, the tool says so instead of looping forever.
How do I generate a secure random number in code?
random_int() in PHP, secrets.randbelow() in Python, crypto.randomInt() in Node and crypto.getRandomValues() in browsers.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools