What is a coin flip, really?
A coin flip is the original random bit. Heads or tails, 50/50, decided in the time it takes a quarter to spin through the air. People have been settling arguments and breaking ties this way since the Romans called it navia aut caput — ship or head — referring to the design on their bronze coins. The math hasn't changed since.
What has changed is that you probably don't carry a coin anymore. A digital coin flip needs to simulate the same fair, unpredictable 50/50 outcome without any physical coin in the room. That sounds trivial. It mostly isn't, because most software uses random number generators that aren't actually random — they're sequences that look random unless you know the formula.
This Coin Flip uses crypto.getRandomValues(), the browser's cryptographically-secure random number generator. Same source banks use for session tokens. Each flip pulls a fresh byte from the operating system's entropy pool and reduces it to a single bit. No seed, no pattern, no way to predict the next outcome from the previous ones. As fair as a fair coin gets.
How to use the Coin Flip
Open the Coin Flip and press flip. That's it.
- Hit the flip button (or press space)
- Watch the result: heads or tails
- Hit it again for the next flip — the counter tracks your running total
- Reset the counter when you want a clean slate
The running total is useful for anyone curious about whether their flips really are balanced. After 100 flips you should see something close to 50/50 — but probably not exactly 50/50. We'll get to why in a moment.
crypto.getRandomValues vs Math.random — why it matters
JavaScript ships with two ways to get a random number, and they aren't equivalent.
Math.random() is a pseudo-random number generator. It produces a deterministic sequence from a hidden internal state. The sequence looks random, and for most use cases — shuffling an animation, picking a random color for a chart — it's fine. But it's not unpredictable. Two pages running the same generator from the same starting state would produce the same "random" numbers. The output is also biased in subtle ways that only matter at scale.
crypto.getRandomValues() pulls bytes from the operating system's cryptographically-secure entropy pool. On modern hardware that pool is fed by thermal noise, mouse movements, network packet timings, and a half-dozen other physical sources. There's no internal state to leak and no sequence to predict. It's the same source the browser uses when it generates a TLS key.
For a coin flip, the difference rarely matters in any single flip. It matters enormously over millions of flips, which is the only context where you'd notice a biased generator. We use crypto.getRandomValues() because there's no good reason not to — both functions take roughly the same time, and one of them gives you a guarantee of fairness you can verify.
If you want to verify this yourself, open the browser console on the Coin Flip page and run crypto.getRandomValues(new Uint8Array(1)). You'll get a number between 0 and 255. We take that number, check whether it's even or odd (or equivalently, whether the lowest bit is 0 or 1), and that single bit decides heads or tails.
The streak problem: why 10 flips rarely looks "random"
Here's an experiment most people get wrong. Flip a coin 10 times. Write down the results. Show them to a friend. Ask: "does this look random?"
If the sequence is H T H T H H T H T T, most people say yes. If it's H H H H T H H T T T, most people say no — too many heads in a row, that can't be random. Both sequences are equally likely. Both have the same overall heads/tails ratio. The second one just looks less random because humans badly underestimate how often streaks happen in real random data.
Worked example. We flipped this Coin Flip ten times. Here's the actual sequence we got:
H, H, T, H, H, H, T, T, T, H
Six heads, four tails. Longest heads streak: 3 in a row (flips 4–6). Longest tails streak: 3 in a row (flips 7–9).
Looks rigged, right? It's not. The probability of getting at least one streak of 3 or more in 10 flips of a fair coin is about 82%. Most ten-flip sequences contain a streak that long. If you don't see one, that's actually the unusual result.
Here are the rough probabilities of seeing different maximum streak lengths in a 10-flip sequence:
| Longest streak of one side in 10 flips | Approximate probability | What this looks like |
|---|---|---|
| 1 in a row (perfect alternation, like H T H T H T H T H T) | ≈ 0.2% | So unlikely it almost never happens with a fair coin |
| 2 in a row at most | ≈ 7% | Rare; would feel "very random" to a human eye |
| 3 in a row at most | ≈ 38% | Common — the typical "looks random" sequence |
| 4 in a row at least once | ≈ 45% | Almost a coin flip itself; feels "biased" to humans but isn't |
| 5 or more in a row at least once | ≈ 22% | Roughly 1 in 5 sequences of 10 flips; feels obviously rigged |
| 6 or more in a row at least once | ≈ 11% | 1 in 9; surprisingly common |
The lesson: long streaks aren't evidence of a broken coin. They're evidence of a normal coin. If you flipped 100 times and never got a streak of 5 or more in either direction, that would be the surprising result.
The gambler's fallacy
You flip heads four times in a row. What's the chance the next flip is tails?
50%. Same as it was for every other flip. The coin doesn't remember the previous outcomes. It can't "owe" you a tails. This is the gambler's fallacy — the intuition that past random results affect future ones — and it's one of the most expensive cognitive errors humans make. Casinos depend on it.
Every coin flip is independent. The probability of HHHHH (five heads in a row) at the start of a sequence is 1/32. But the probability of getting another head after already flipping HHHH is still 1/2. The earlier flips happened. They don't influence the next one.
This matters for any honest use of a coin flip. If you're using flips to make a decision — should we order pizza or sushi? — don't keep flipping until you get the answer you wanted. That defeats the entire point of letting chance decide. Flip once, accept the result.
What people actually use a coin flip for
The Coin Flip gets used for more than tie-breaking. A few common cases:
- Deciding between two options. Pizza or sushi. Movie A or movie B. The classic use, and still the best one. Two outcomes, equal weight, no overthinking.
- Removing your own bias from a hard choice. If you flip a coin and immediately feel disappointed by the result, you've learned something — you already knew which option you wanted. The flip surfaces preferences you weren't admitting.
- Settling games and sports. Kickoff in football, serve in tennis, first pick in a draft. Coins decide who goes first in roughly every competitive structure invented before computers.
- Random sampling. "Flip a coin — if it's heads, include this row in the sample." Quick way to take a 50% random sample of anything.
- Teaching probability. Coin flips are the cleanest classroom example of independent trials, expected value, and the law of large numbers. Run a hundred and watch the ratio converge.
For decisions with more than two options, you'll want a different tool. The Dice Roller handles 4, 6, 8, or 20 outcomes. The Random Name Picker picks one item from a list. The List Randomizer shuffles a whole list into a random order.
What about "best of three"?
If a single coin flip feels too high-variance, "best of three" reduces the noise. Three flips, and whichever side gets to 2 first wins. The probability each side wins is still 50% — the underlying coin is the same — but the spread of possible outcomes is narrower.
The math: best-of-three is just "first to 2 heads or 2 tails in a series of independent flips." Either side wins as soon as they get the second one. Most series end in 2 flips (probability 50%), the rest end in 3 (probability 50%).
Worked example: you and a friend both want the last slice of pizza. Single flip, you'd accept the result but maybe grumble. Best of three feels fairer because there's no way to lose on the first roll of the dice. The expected outcome is identical; the felt fairness is higher. Use whichever your peer group prefers — both are mathematically fine.
Related randomness tools
The Coin Flip is the simplest case of "I need a random outcome right now." A few related Microapps for richer cases:
- Dice Roller — for more than two outcomes. Roll any number of dice with 2, 4, 6, 8, 10, 12, 20, or 100 sides.
- List Randomizer — paste a list, get it back in random order. Good for shuffling presentation order, queue order, or anything that needs to be sequenced fairly.
- Random Name Picker — pick one item from a list. The "pick a winner" use case.
- Team Generator — split a roster of people into balanced random teams. Useful for sports, study groups, or splitting a class.
- Password Generator — uses the same cryptographic randomness source for actual security-grade output.
Frequently asked questions
Is this Coin Flip really 50/50?
Yes. Each flip pulls a random byte from crypto.getRandomValues() and checks whether it's even or odd. The function is the browser's cryptographically-secure RNG, the same one used to generate TLS session keys. Bias would be measurable in the millions of flips; you won't find any.
I flipped heads 7 times in a row. Is the coin broken?
No. The probability of any specific 7-flip sequence (including HHHHHHH) is 1/128 — about 0.8%. If you flip 100 times, you'll probably see a streak that long somewhere in the sequence. Streaks don't mean the coin is biased; they mean the coin is normal.
Why does my running total drift away from 50/50?
Random sequences have what statisticians call random walk drift. After 100 flips, the count won't usually be 50/50 — it'll be somewhere in the 40s and 50s on each side. After 10,000 flips it'll be much closer in absolute terms (say, 5,021 vs 4,979) but the absolute gap can still be in the dozens. Convergence is in ratio, not absolute count. This is the law of large numbers, and it's slow.
Can I flip a weighted coin (60/40 or 70/30)?
The Coin Flip is fair-only by design. For weighted random choices, use the Dice Roller with a larger die and define your own ranges (e.g. roll a d10; 1–6 means option A, 7–10 means option B is a 60/40 split). Building "weighted coin" into a coin flip muddies what the tool does. One job per Microapp.
Does the Coin Flip work offline?
Yes, once the page is loaded. The random number generator runs entirely in your browser; nothing about the flip leaves your device. No network call, no server, no tracking. Open it once, drop your wifi, keep flipping.
Can I use this for a tournament bracket or important decision?
The randomness is fair. For high-stakes decisions where the loser might dispute the result, consider doing the flip with a witness watching the screen, or take a screenshot of the result with a visible timestamp. The coin doesn't lie, but social proof that the flip happened can matter when the result has consequences.
Why not just use a physical coin?
Use one if you have one. Physical coins are fine for fairness, with a small caveat — research suggests that real coins are very slightly biased to land on the same side they started on (about 51/49) because of how they wobble in the air. This Coin Flip doesn't have a "starting side," so it's actually a tiny bit fairer than a physical coin. But you're not going to notice the difference in 10 flips.