Random Number Generator

Generate one or many random numbers in any range.

Ad Slot — Top Banner
Result
📖 Read the full guide: Random Numbers: True, Pseudo-Random and Cryptographically Secure In-depth article explaining the math and real-world context.
Ad Slot — In-Content

True Random vs Pseudo-Random

This generator uses your browser's built-in pseudo-random number generator (PRNG) — specifically Math.random(), which implements an algorithm like xorshift or a similar fast PRNG. PRNGs produce sequences that look random but are deterministic given a starting seed. For raffles, games, demos, and homework, that's more than enough. For cryptography or unpredictability-critical use, switch to crypto.getRandomValues(), which pulls from operating-system entropy sources.

For true physically-random numbers (from atmospheric noise or quantum sources), random.org is the standard reference — they generate true randomness from atmospheric radio noise and have been operating since 1998.

Common Uses

  • Lottery number picker — set count to the number of balls, range to the maximum number
  • Raffle / draw winner — set count to 1, range to total entries
  • Decision maker — set range 1-2 and let chance decide
  • Statistical sampling — generate N unique values across a population
  • Random group assignment — shuffle a list, split into groups
  • Dice replacement — range 1-6 (or 1-20 for D&D)
  • Password generation — better to use the dedicated password generator which uses crypto-strength randomness

The Math of Randomness

With n equally likely outcomes, each has probability 1/n. Multiple independent draws follow combinatorial probability. The Wikipedia article on probability theory covers the foundations.

Frequently Asked Questions

Why aren't my "random" lottery picks winning?

Because lottery odds are astronomically low. The Mega Millions jackpot is 1 in 302 million per ticket. Random selection has the same expected return as choosing birthdays or any other system — the games are designed so no strategy beats luck.

Is Math.random() really random?

No — it's pseudo-random, deterministic given the seed. Modern browsers seed from system entropy, so practically you can't predict the output without massive effort. Good enough for games and apps; not good enough for crypto.

How do I generate truly random numbers?

Use crypto.getRandomValues() in modern browsers (Web Crypto API), or visit random.org for atmospheric-noise-based randomness.