Random Number Generator
Options
Output
Technical details
How the Random Number Generator Works
What the Tool Does
The Random Number Generator produces cryptographically strong random integers or floating-point numbers using the Web Crypto API (crypto.getRandomValues). It employs rejection sampling to eliminate modulo bias, ensuring uniform distribution across any specified range. You can generate single values or batches of random numbers with configurable minimum, maximum, and precision settings.
Common Developer Use Cases
Developers use cryptographic random number generators for security-sensitive tasks like generating unguessable session tokens, nonces, lottery picks, or random sampling from datasets. Game developers use it for dice rolls and procedural generation when fairness matters. QA engineers generate random test inputs for fuzz testing, and data scientists use it for random sampling when reproducibility is not required.
Data Formats, Types, or Variants
The tool supports integer generation within an arbitrary range (inclusive bounds) and floating-point generation with configurable decimal precision. Rejection sampling discards values that would cause modulo bias when the range does not evenly divide the random source's output space. The underlying entropy comes from the operating system's CSPRNG (CryptGenRandom on Windows, /dev/urandom on Unix) surfaced through the browser's Web Crypto API.
Common Pitfalls and Edge Cases
Cryptographic randomness is slower than Math.random() and unnecessary for non-security uses like shuffling a playlist. Rejection sampling can theoretically loop many times for pathological ranges, though in practice this is negligible. Browser-generated random numbers cannot be seeded for reproducibility — if you need deterministic sequences for testing, use a seeded PRNG instead. The maximum safe integer range is bounded by JavaScript's Number.MAX_SAFE_INTEGER (2^53 - 1).
When to Use This Tool vs Code
Use this browser tool when you need a quick unbiased random number for a one-off decision, manual testing, or verifying that your own implementation produces values within expected ranges. For production use, call crypto.getRandomValues() directly in your code or use language-native CSPRNG functions (secrets module in Python, SecureRandom in Java) that integrate with your application's error handling and logging.