Random Number Generator
Generate random numbers with various options and ranges.
Code Examples
// Pseudorandom (0-1)
Math.random();
// Random integer in range
Math.floor(Math.random() * (max - min + 1)) + min;
// Cryptographically secure
crypto.getRandomValues(new Uint32Array(1))[0];Frequently Asked Questions
Are these random numbers truly random?
The cryptographic option uses your browser's crypto.getRandomValues() which provides cryptographically strong random values. Standard mode uses Math.random() which is pseudorandom.
When should I use cryptographically secure random numbers?
Any time the value must be unpredictable to an attacker: tokens, session IDs, password reset codes, keys, or lottery draws. For simulations, sampling, and games, Math.random() is fine and faster.
Can I generate random numbers in a specific range?
Yes. Set the minimum and maximum, and the generator produces uniformly distributed integers in that inclusive range. You can also generate several values at once.
Related Tools
This tool runs entirely in your browser - nothing you enter is uploaded or stored.