Is the coin toss fair?
A plain-English look at how the site generates a balanced digital result, and what that does and does not prove.
The Problem with Math.random()
Most simple online coin toss tools use the built-in JavaScript function Math.random(). While this is fine for a quick game, it is not considered cryptographically secure.
Math.random() relies on a pseudo-random number generator (PRNG) that is designed for speed, not absolute mathematical unpredictability. If an attacker observed enough outputs, they could theoretically predict the next sequence of numbers.
The Solution: Web Crypto API
At cointoss.uk, we use the modern Web Crypto API, specifically crypto.getRandomValues().
The browser obtains cryptographically strong random values from the operating system. That makes the result difficult to predict, but no browser page can promise more than the guarantees provided by the device and browser running it.
How We Process The Result
When you click the flip button, our script requests a single byte of random data from your operating system. A byte is a number between 0 and 255. We then use the modulo operator (% 2) to determine if the number is even or odd. Even numbers become Heads, and odd numbers become Tails.
const array = new Uint8Array(1);
crypto.getRandomValues(array);
const side = array[0] % 2; // 0 for Heads, 1 for Tails
Because 256 is evenly divisible by two, the even/odd mapping gives each side the same probability. That describes the digital method; it is not a claim that a real coin is millions of times less fair.
Physical Coin Bias
Real coins are not perfectly fair. In 2007, Stanford statistician Persi Diaconis and colleagues published research showing that a coin tossed in the conventional way — spun in the air and caught — lands on the same face it started on roughly 51% of the time. This small but measurable bias arises from the physics of the flip: the coin's initial orientation, the angular momentum imparted by the thumb, and air resistance all conspire to make the outcome slightly predictable.
The 2007 Diaconis, Holmes, and Montgomery paper modelled a same-side tendency of about 51% for a natural caught toss. A later study of 350,757 human flips measured a same-side rate of 50.8%, while heads and tails remained balanced when the starting face was random. The size and method of a physical coin still matter, so this is a useful result, not a universal constant.
The digital result does not depend on the weight of a coin, the force of a throw, or its starting orientation. Instead, the browser supplies a random byte and the site maps exactly half of the possible byte values to each side.
Verifying Fairness
One strength of client-side randomness is that the decision code is visible in the browser. Open the developer tools, set a breakpoint on the flip function, and inspect the generated value and the even/odd mapping. This lets you inspect the implementation; it does not independently prove the browser or device is trustworthy.
Unlike a server-only result, the decision code is delivered to your browser and can be inspected. The random bytes come through the browser, and the decision logic — even or odd — is straightforward to audit. If you run 1,000 flips, the totals will usually be near 500 heads and 500 tails, but noticeable variation is normal.
You can log values while inspecting the page and run your own statistical checks, but a finite sample cannot confirm perfect uniformity. A chi-squared test can identify some departures from an expected distribution; it is not a proof of fairness.
The result is generated client-side, while anonymous event data is sent separately for the site's overall counters. The source and mapping are simple to inspect, but the page should not be treated as a cryptographic audit service.