Coin Flip

Flip a virtual coin — fair, fast, with running heads/tails tally.

How this works

A digital coin flip used to settle yes/no questions, pick who goes first, or break ties when neither side will give. The widget pulls a single random bit from `crypto.getRandomValues` (the same RNG browsers use for security tokens), so the result is exactly 50/50 — no biased Math.random shortcuts. A short tumble animation gives visible feedback that something happened, then the result locks in. The history strip keeps the last 30 results so you can see the flips you actually got rather than the one your memory says you should have, and the running tally is updated on every flip — useful for proving fairness or showing kids how the law of large numbers works.

People have been using coin flips to settle disputes for at least two thousand years. The Romans called it *navia aut caput* — "ship or head" — referring to the figures stamped on either side of their bronze coins. Calling a flip is still the standard tie-breaker in modern sports (the NFL coin toss decides who receives the opening kickoff; cricket's toss decides who bats first), in legislative procedure (a tied vote in many US state legislatures is broken by coin flip), and even in city-naming history — Portland, Oregon was named by a coin flip in 1845 between two settlers from Boston and Portland, Maine.

A quick note on real-world coins versus this calculator: in 2007 a team led by Stanford statistician Persi Diaconis showed that physical coin flips are very slightly biased toward landing on whichever side started face-up — about 51% versus 49%, because the coin spends marginally more time with that side facing the air. A 2023 follow-up study with 350,000 hand-flipped coins reproduced the result. For most everyday decisions the bias is invisible — you'd need to flip ten thousand times to reliably detect it. The digital version on this page has no such bias: bytes from a CSPRNG don't care which way the coin "started".

The formula

bit ← crypto.getRandomValues(Uint8Array(1))[0] & 1 result ← bit == 0 ? Heads : Tails

crypto.getRandomValues fills a buffer with cryptographically-secure random bytes drawn from a CSPRNG seeded by the operating system. Masking with `& 1` keeps just the lowest bit, which is uniformly 0 or 1 — i.e. exactly 50/50. Math.random would have given the same statistical fairness for this use, but using getRandomValues lets us tell users "fair" without any caveats about implementation quirks.

Example calculation

  • Tap "Flip the coin".
  • A random byte is read; its lowest bit decides the result.
  • Bit = 0 → Heads. Bit = 1 → Tails.
  • After enough flips the heads/tails ratio converges to 50/50 — the law of large numbers in action.

Frequently asked questions

Is this actually fair, or biased toward one side?

Genuinely 50/50. Each flip pulls a fresh byte from the browser's cryptographic RNG and uses its lowest bit. There's no hidden state, no streak-correction, no "due for tails" logic. In a small sample (10–20 flips) you'll often see runs of 4–6 heads or tails in a row — that's normal random behaviour, not a bias. Run 1,000 flips and the count will sit within a few percent of 500/500.

Why does the coin "tumble" before showing the result?

Pure UX. The result is decided the instant you tap the button — the bit is pulled and stored — but a 480ms tumble gives the brain time to register that something happened. Showing the answer instantly feels broken ("did it even flip?"), and waiting longer than half a second feels slow. 480ms is roughly the duration of a real-world coin toss in the air.

Can I trust the result for important decisions?

Statistically, yes — the math is sound. But the bigger question is whether you should be flipping a coin for the decision at all. If you're using it because you genuinely don't have a preference (which way to walk for lunch, who picks the next movie), the coin is fine. If you're using it because two options are tied on apparent merit but you secretly hope for one, listen to your reaction the moment the coin lands — that gut response is more useful information than the flip itself.

Is there a way to do "best of 3" or "best of 5"?

Not as a built-in mode — but the running tally and history strip together cover the same ground. Flip three times, look at the count, take the side with two or more wins. That said, "best of N" doesn't actually change the odds: if you'd accept a single 50/50 flip, three flips with a majority rule is also 50/50. People reach for it when they want the appearance of more deliberation than they really have, which usually means the underlying decision deserves a different decision-making method, not more flips.

Are real coins actually 50/50 in real life?

Almost — but not quite. The most reliable study to date (Bartoš et al., 2023, building on earlier work by Persi Diaconis) recorded 350,757 hand-flipped coin tosses across 46 different coins and found that coins land on the same side they started on about 50.8% of the time. The bias comes from the fact that flipped coins precess (wobble) rather than rotating around a perfectly horizontal axis, which leaves the starting side fractionally more time facing up. For everyday use the bias is undetectable — you'd need hundreds of flips to even start to see it. If you want a guaranteed 50/50, the digital version on this page has no such bias.

If I just got 5 heads in a row, is tails 'due'?

No. This is the classic gambler's fallacy. The coin has no memory — every flip is independent, and the probability of heads on the next flip is still 50% no matter what came before. A run of 5 heads is unusual but not rare (it happens roughly once every 32 sequences of 5 flips). What's true is that long runs of any one outcome become less likely the longer you flip — but that's about the overall distribution, not about the next individual flip. If you'd correctly say "the next flip is 50/50" before any of the 5 heads happened, that statement is still true after them.

If it's 50/50, why not just decide for myself?

That's often the right answer, and it's the one a coin flip can help you reach. There's a well-known psychological trick: flip a coin for a tough decision, and pay attention to your reaction in the moment the result lands. Relief that it came up the way you wanted means you'd already made the choice; disappointment means the same in reverse. The coin's job in those cases isn't to *make* the decision — it's to surface the preference you couldn't admit to yourself. For genuine indifference (which way to walk for coffee, who picks the playlist), skipping deliberation altogether is fine, and a coin is just a fast way to do that without anyone feeling overruled.

Related calculators