Coin flip
Fair coin flip using crypto.getRandomValues.
A Coin Flip computes coin flip from the inputs you provide. It applies the standard formula to the values you enter and returns the result instantly, without sending any data to a server. Single flip or batch of N flips.
Fair coin flip using crypto.getRandomValues.
Animated coin. Single flip or batch of 100.
This coin flipper settles a yes/no decision or runs a batch of trials so you can watch probability in action. Each flip is a Bernoulli trial with a 0.5 chance of heads and 0.5 chance of tails. Crucially, the flips are drawn from crypto.getRandomValues, the browser's cryptographically secure random source, not the weaker Math.random, so there is no detectable bias or pattern even across thousands of flips.
Two ideas explain almost everything people get wrong about coins. The gambler's fallacy is the false belief that a run of heads makes tails "due"; in reality every flip is independent and the next one is still exactly 50/50. The law of large numbers is the true statement that the observed proportion of heads converges toward 50 percent as the number of flips grows, even though the absolute gap between heads and tails counts can keep widening. Both can be true at once, and the batch mode above lets you see it.
Flipping a coin to decide is ancient. The Romans called it "navia aut caput" (ship or head, after the imagery on their coins), and the toss has settled disputes ever since because it is fast, visible, and accepted as fair by both sides. Today it opens every American football game, breaks ties in some local elections by law, and even decided the 1968 European Cup semi-final between Italy and the Soviet Union. The appeal is procedural fairness: when no option is clearly better, a verifiable 50/50 draw lets everyone agree the outcome was impartial rather than chosen.
For a single flip the math is trivial; the interesting part is what happens across many flips. The expected number of heads in n flips and the spread around that expectation follow the binomial distribution.
P(heads on one flip) = 0.5 Expected heads in n flips = 0.5 x n Standard deviation = sqrt(n x 0.5 x 0.5) = 0.5 x sqrt(n) Observed heads % = (heads / n) x 100 -> tends to 50% as n grows
Suppose you flip the coin 100 times and get 57 heads, 43 tails. Is that suspicious?
| Scenario | Probability | As odds / percent |
|---|---|---|
| 1 heads in a row | 1/2 | 50% |
| 2 heads in a row | 1/4 | 25% |
| 3 heads in a row | 1/8 | 12.5% |
| 5 heads in a row | 1/32 | 3.13% |
| 10 heads in a row | 1/1024 | 0.098% |
| Exactly 50 heads in 100 flips | ~0.0796 | ~7.96% |
| At least one head in 5 flips | 31/32 | 96.9% |
Math.random, which is not designed to be unpredictable. This tool uses the cryptographic generator instead.Yes. It draws bits from crypto.getRandomValues, the browser's cryptographically secure random number generator, rather than the predictable Math.random. Each flip has an unbiased 50 percent chance of heads and 50 percent of tails with no detectable pattern.
No. Each flip is independent, so after five heads the next flip is still exactly 50/50. Believing the coin is "due" for tails is the gambler's fallacy. The coin has no memory of past results.
Random variation. In 100 flips the standard deviation is 5 heads, so anything from about 40 to 60 heads is normal. The percentage converges to 50 as you flip more (the law of large numbers), but the exact count almost never lands on the midpoint.
One in 1,024, or about 0.098 percent. Each additional head halves the probability: two in a row is 1/4, three is 1/8, and ten is (1/2) to the tenth power, which equals 1/1024.
Almost, but not perfectly. A 2007 Stanford study by Persi Diaconis found a spinning or flipped physical coin has a tiny bias (around 51 percent) toward the side that started face up, because of wobble during the flip. A digital flip like this one removes that physical bias entirely.