You are about to settle something with a coin flip, and a doubt shows up: can a button on a web page really be as fair as a real coin?

It is the right question to ask. It just has a surprising answer, because it quietly assumes the physical coin is the honest benchmark.

In 2023, a team of researchers published the result of flipping real coins 350,757 times — the largest experiment of its kind ever run. They were testing a physics prediction made by Persi Diaconis, Susan Holmes and Richard Montgomery back in 2007: that a tossed coin does not tumble symmetrically, and therefore lands on the side it started on slightly more often than chance allows.

The prediction was about 51%. The measured result was 50.8%, with a 95% credible interval of [0.506, 0.509]. The physical coin is measurably biased.

So the honest comparison is not "software versus the real thing". It is one imperfect method against another — and this is one of the rare cases where the software wins outright. Here is why, and where it stops being true.

What 350,757 Real Flips Revealed

The detail that matters most in that study is the one that usually gets lost when it is summarised as "coin flips aren't 50/50".

The bias is not toward heads. Across all 350,757 flips, the researchers measured Pr(heads) = 0.500, with a 95% interval of [0.498, 0.502]. Heads and tails came up equally often, exactly as you would hope.

The bias is toward the side that was facing up before the toss. That is a completely different claim, and it has a practical consequence:

  • If you never look at how the coin sits on the thumb, a real toss is fair to you. You cannot exploit a bias you cannot observe.
  • If you can see the starting side — and in a real room, standing next to the person tossing, you usually can — you are looking at roughly a 50.8% shot instead of 50%.

The effect also varied noticeably between individuals. Some flippers showed a clear same-side tendency, others showed none, which the authors attribute to differences in flipping technique. In other words the fairness of a real toss depends on who is tossing.

Spinning is far worse than flipping Diaconis has long pointed out that a coin spun on a table is a different beast entirely. A spun US penny lands tails up around 80% of the time, because the rim carries slightly more metal on one side. Flipping through the air mostly cancels that out; spinning does not. If someone offers to spin rather than toss, decline.

What Makes a Digital Flip Fair

A virtual coin has no rim, no centre of gravity and no starting side, so none of the physical biases have anything to attach to. What it has instead is one line of arithmetic.

const isTails = Math.random() < 0.5;

Math.random() returns a value in the interval [0, 1) — zero is possible, one is not. The condition < 0.5 splits that interval into two pieces:

  • [0, 0.5) — tails
  • [0.5, 1) — heads

Those two pieces are exactly the same width. Not approximately, not close enough — identical. There is no rounding step where a fraction of a percent could leak to one side, and no state carried from the previous flip. Every call starts from the same 50/50 split.

That is the whole reason a digital coin can beat a metal one. It is not that the generator is better than physics. It is that the question has been reduced to cutting a line segment in half, and a line segment can be cut in half perfectly.

Pseudo-Random Is Not a Weasel Word

Any honest description of Math.random() calls it pseudo-random, and that word makes people nervous. It should not — but it does mean something specific, so it is worth pinning down.

A pseudo-random generator starts from a hidden internal state and produces numbers by a fixed rule. It is deterministic: identical state in, identical number out. Nothing about the flip is drawn from atmospheric noise or radioactive decay.

What matters is how good the rule is. In V8 — the engine behind Chrome and Edge — Math.random() uses an algorithm called xorshift128+. It carries 128 bits of internal state, has a period of 2128 − 1 before it could ever repeat, and passes the TestU01 statistical suite. It replaced an older, genuinely weak implementation back in Chrome 49.

For deciding who buys lunch, that is not merely adequate; the statistical flaws are far too small to surface in the handful of flips a person will ever perform.

The one real limitation xorshift128+ is not cryptographically secure. Given enough observed outputs, its internal state can be reconstructed and future values predicted. That is irrelevant to a coin flip and disqualifying for anything where someone has a motive to cheat — passwords, tokens, cryptographic keys. Those need crypto.getRandomValues(), which is a different mechanism entirely.

Why Five Heads in a Row Looks Broken

This is the complaint every random tool receives, and it is almost always a misreading of what randomness looks like up close.

Flip ten coins and a run of three or more identical results does not just happen occasionally — it is the normal case. Here is the exact distribution, computed by enumerating all 210 = 1,024 possible ten-flip sequences rather than by simulation:

Longest streak in 10 flipsChance of seeing it
3 or more in a row82.62%
4 or more in a row46.48%
5 or more in a row21.68%
6 or more in a row9.38%

Read the first row again. In ten flips, a streak of three is more likely than not — it shows up better than four times in five. The average longest run across all 1,024 sequences is 3.66. A result with no streak at all would be the genuinely odd outcome.

The reverse intuition is just as wrong. A perfectly even split feels like the "expected" result, and it is the single most likely one — but it is still rare in absolute terms:

FlipsChance of an exactly even split
10 flips24.61% — an exact 5/5
20 flips17.62% — an exact 10/10
100 flips7.96% — an exact 50/50

Three times out of four, ten fair flips will not give you five and five. Lumpiness is the signature of real randomness. It is a sequence that looks tidy and alternating that should make you suspicious.

Reading the Running Tally

The tool keeps a cumulative heads/tails count across your session, and the tally is where the previous section becomes something you can watch happen.

Fairness does not mean the counts stay level. It means the ratio drifts toward 50% as the count grows, while the raw gap between the two numbers is free to wander. Exact binomial probabilities for landing within 45–55% heads:

Total flipsChance the tally sits between 45% and 55% heads
1024.61%
5052.01%
10072.87%
50097.75%
1,00099.86%

At ten flips a 7/3 split is thoroughly unremarkable. By a thousand, a tally outside 45–55% would happen roughly once in seven hundred sessions. If your numbers look skewed, the fix is not a better generator — it is more flips.

The trap the tally sets After five heads, tails does not become "due". The generator has no memory of the previous call, so the next flip is 50/50 exactly as the first one was. Believing otherwise is the gambler's fallacy, and a visible running tally is precisely the thing that tempts people into it. The tally is there to show convergence over many flips — not to forecast the next one.

When You Should Not Use It

A coin flip is the right tool for a narrow job: two options, no preference, and nobody with a real incentive to game the outcome. Outside that, reach for something else.

  • More than two options. Flipping repeatedly to narrow down a list of five does not give each entry an equal chance. The Random Picker selects from a list directly, at genuinely equal odds.
  • You need a number, not a side. For a value in a range — a test fixture, a sample row, a raffle position — the Random Number Generator covers the whole range in one call instead of stitching bits together from flips, and its repeat behaviour has odds worth knowing before you draw more than one.
  • Game odds beyond 50/50. Tabletop rules are built around dice distributions, and two dice are not a flat spread. The Dice Roller handles the standard sets.
  • Money, prizes or security. Anything auditable or adversarial needs a verifiable, cryptographically secure source with a published seed. No convenience tool — this one included — should be the deciding authority there.

All four random tools share the same generator and the same principle, so if you are comparing them the choice is only about shape of output. They are grouped under Random Tools.

Flipping a Coin on CodBolt

  1. Open the Flip a Coin tool.
  2. Enter how many coins you want, from 1 to 10. Each one is drawn independently — flipping five at once is not the same event repeated, it is five separate 50/50 draws.
  3. Press Flip Coin and let the animation finish. The label under each coin confirms the result in text, so there is no ambiguity about which face you are looking at.
  4. Check the running tally underneath for the session totals, and the recent-flips list for the last ten rounds in order.
  5. Use Clear to wipe the history and reset the tally back to zero when you want a clean run.

Every flip is generated in your browser. Nothing is sent anywhere, which also means nobody — including this site — can see or influence a result before you do.

Settling something with more than two sides Choosing between named options rather than heads and tails? Random Picker takes the list as it is. Need a value inside a range instead? Random Number Generator handles that in one draw. And for anything governed by game rules, the Dice Roller gives you the standard dice.
Try it now — CodBolt Flip a Coin

Exact 50/50 odds, up to 10 coins at once, with a running tally. Free and 100% private.

Open Tool