Random Numbers Explained: True Randomness vs Pseudorandomness
Runs 100% in your browser — nothing on this page is uploaded or stored. Every "random number generator" — from dice to JavaScript's Math.random() — sits somewhere on a spectrum between genuinely unpredictable and merely unpredictable-looking. Where a generator sits on that spectrum decides whether it's fine for a card game or dangerously wrong for a password. This guide explains the difference, with the practical rules that follow from it.
What "random" actually means
A sequence is random when each value is unpredictable: knowing all previous values gives you no useful information about the next one. That's the whole definition, and it's stricter than it sounds. A sequence like 7, 7, 7, 7, 7 could be perfectly random (a fair process can repeat); a sequence like 1, 2, 3, 4, 5 is not random even though it "looks varied." Randomness is a property of the process, not the output.
This is why human "random" choices fail. Ask people to pick a "random" number from 1–10 and most say 7; ask for a random password and they produce pronounceable syllables with a digit at the end. Humans are pattern machines — we're the worst random number generators in the room. Any time unpredictability matters, delegate to a proper source, not your intuition. (Our password generator exists precisely because of this.)
True randomness: borrowing unpredictability from physics
True random number generators (TRNGs) harvest unpredictability from physical processes: atmospheric noise, thermal noise in circuits, precise timing of your keystrokes and mouse movements, even quantum phenomena. Because these processes aren't deterministic, their output can't be predicted even in principle.
Your operating system maintains an entropy pool fed by such sources — hardware timings, interrupt jitter, and on modern machines, dedicated randomness instructions in the CPU. When a program asks the OS for random bytes, it draws from this pool. This is the gold standard, and it's what browsers expose to web pages through the WebCrypto API (crypto.getRandomValues()). Every password our generator creates comes from this source.
The limitation is speed: harvesting physical randomness is slow, and a freshly booted machine may not have collected much entropy yet.
Pseudorandomness: deterministic, but unpredictable in practice
Pseudorandom number generators (PRNGs) are algorithms: start with a seed value, then apply deterministic math to produce a sequence that looks random. The critical property: the same seed always produces the same sequence. That's a feature, not a bug — it makes simulations reproducible. Run a scientific simulation with seed 42 today and seed 42 next year, and you get identical results to compare.
Whether a PRNG is "good enough" depends entirely on the use case:
- Ordinary PRNGs (like JavaScript's
Math.random()) are designed for speed and statistical evenness — games, shuffling a playlist, procedural graphics. They are not designed to resist prediction: given enough outputs, an attacker can often reconstruct the internal state and predict everything after. Never use them for passwords, tokens, or anything security-related. - Cryptographically secure PRNGs (CSPRNGs) are PRNGs designed so that predicting the next output is computationally infeasible even after seeing a long stretch of previous outputs. Your OS's random source and the WebCrypto API are CSPRNGs seeded from true entropy — the right tool for passwords, session tokens, and encryption keys.
The seed is everything
A PRNG is only as unpredictable as its seed. Seed a generator with the current time in milliseconds and anyone who knows roughly when you ran it can reproduce your entire "random" sequence — this has broken real-world systems, from online poker shuffles to password reset tokens. Secure systems seed from the OS entropy pool, never from the clock alone.
This also explains an old puzzle: why do "random" playlists and shuffles sometimes feel non-random? A correct shuffle can play the same artist twice in a row — true randomness has no memory. Music apps eventually learned to make shuffles less random (spreading artists out) because users perceived genuine randomness as broken. Perception and mathematics disagree; for user-facing features, perception sometimes wins.
Where good randomness actually matters
- Passwords and passphrases. The highest-stakes everyday use. Each character or word must be unpredictable — see our guide on creating strong passwords for the entropy math, and use a generator backed by cryptographic randomness.
- Security tokens. Session IDs, password-reset links, API keys, and anything where "guessable" means "compromised." All need a CSPRNG.
- Fair draws and sampling. Lotteries, random audits, A/B test assignment, jury selection — anywhere bias (or the appearance of bias) destroys trust.
- Diceware passphrases. Rolling physical dice to pick words from a 7,776-word list gives each word about 12.9 bits of entropy. Five words ≈ 64 bits. You can check the word count of any passphrase with our word counter — but generate the words with dice or a CSPRNG, never by inventing them.
Where it doesn't matter (much)
- Games and visual effects.
Math.random()is fine for particle effects, procedural terrain, and casual games — nobody's attacking your confetti animation. - Simulations and testing. Here you want a seeded PRNG so results are reproducible. True randomness would be a liability.
- Shuffling for personal use. Randomizing a study deck or a playlist doesn't need cryptographic strength.
The one-paragraph version
True randomness comes from unpredictable physical processes; pseudorandomness comes from deterministic algorithms seeded with a starting value. For anything security-related — passwords, tokens, keys — you need a cryptographically secure source (your OS's entropy pool, exposed in browsers as WebCrypto), because ordinary generators like Math.random() can be reverse-engineered. For games and simulations, an ordinary seeded PRNG is not just fine but often preferable. And for everything: don't trust your own brain to be random — it isn't.
Frequently asked questions
Is Math.random() truly random?
No. It's a pseudorandom generator: deterministic, seeded internally, and not designed to resist prediction. It's fine for games and visual effects, but never use it for passwords, tokens, or anything where an attacker benefits from guessing the output.
What is the difference between random and pseudorandom?
Truly random output comes from a non-deterministic physical process and is unpredictable even in principle. Pseudorandom output comes from a deterministic algorithm starting from a seed — the same seed always gives the same sequence. A cryptographically secure PRNG seeded from true entropy is unpredictable in practice, which is what security needs.
Can humans generate random numbers?
Badly. People favor certain numbers (7 is the classic), avoid repeats that genuine randomness produces, and build unconscious patterns. Studies consistently show human-generated "random" sequences fail statistical tests. Use dice, coins, or a proper generator instead.
How do online casinos generate random numbers?
Regulated ones use certified hardware random number generators or cryptographic PRNGs seeded from hardware entropy, and they're audited by testing labs. The certification — not the algorithm alone — is what makes them trustworthy. An uncertified site's "random" shuffle is just a claim.
What is a seed in random number generation?
The starting value fed into a pseudorandom algorithm. The same seed always reproduces the same sequence, which makes simulations reproducible — and which is why seeds must themselves be unpredictable (drawn from OS entropy, not the clock) for security uses.
How many random words make a secure passphrase?
Five words drawn randomly from a 7,776-word diceware list gives about 64 bits of entropy — roughly 90,000 years against a fast offline attack. The words must be randomly selected (dice or a secure generator), not chosen by you. Our password guide works through the full math.
Generate randomness you can trust
Need unpredictable output right now? Our password generator draws from your browser's cryptographic randomness — the same WebCrypto source described above — and nothing ever leaves your device.