Coin Flip Simulator
Flip a coin one or ten thousand times — see the heads/tails ratio, the longest run, and (for small samples) the full sequence.
Math.random()-based — fine for stats / demos, not for cryptographic draws.
How to use
- Enter how many flips to simulate (1 to 10,000 — values outside this range are clamped).
- Set the probability of heads with the bias slider; leave it at 50% for a fair coin.
- Click Flip to run the whole experiment at once.
- Compare the observed heads count and ratio with the expected heads (flips × probability).
- For runs of 1,000 flips or fewer, review or copy the full H/T sequence shown below the statistics.
About this tool
ShowHide
Run a coin-flip experiment of anywhere from a single toss to 10,000 flips in one click. The bias slider sets the probability of heads between 1% and 99%, so you can model an unfair coin as easily as a fair one. After each run you get the heads and tails counts, the observed heads ratio alongside the expected count (flips × probability), and the longest streak of each side; for runs of up to 1,000 flips the full H/T sequence is rendered so you can eyeball the streaks and copy them out.
Flips are generated client-side with the browser's Math.random() — a fast pseudorandom generator that is statistically fine for simulations, classroom demos, and building probability intuition, but not suitable for lotteries or anything adversarial. The statistics are a nice illustration of probability in action: the ratio converges toward the slider setting as the sample grows (the law of large numbers), yet the longest run keeps growing roughly like log2 of the number of flips — genuine randomness is far streakier than most people expect.
Frequently asked questions
Why does a fair coin produce such long streaks?
In a fair sequence of N flips the longest run of one side is typically around log2(N): about 7 in 100 flips, and 10 or more in 1,000. A long streak is expected behavior, not evidence the coin is rigged — human-invented 'random' sequences are usually detectable precisely because they avoid streaks like this.
How close should the heads ratio land to the slider value?
The heads count follows a binomial distribution with standard deviation √(n·p·(1−p)). For a fair coin that means deviations of roughly ±5 percentage points are normal at 100 flips, but only about ±0.5 at 10,000 — increase the sample size and watch the ratio tighten.
Is this cryptographically random?
No. Flips come from Math.random(), a fast pseudorandom generator. That's fine for statistics, demos, and games, but for raffles, security decisions, or anything where a motivated party benefits from bias, use a cryptographically secure or verifiable random source instead.
Why doesn't the sequence appear for big runs?
The raw H/T string is rendered only for runs of up to 1,000 flips to keep the page responsive. The statistics, however, are always computed over the full run, so a 10,000-flip experiment still reports exact counts and longest streaks.
Can I use it for a single decision flip?
Yes — set flips to 1 and click. Each click is an independent experiment: previous results have no influence on the next one, so a string of heads does not make tails 'due' (that's the gambler's fallacy).
Guides on this topic
Related tools
Random Distribution Generator
Generate samples from uniform, normal, exponential, Poisson, Bernoulli, or triangular distributions — with histogram, summary stats, and CSV/JSON export.
Random
Dice & Coin Roller
Roll polyhedral dice (d4–d100) or flip a coin with cryptographic randomness.
Random
Weighted Random Picker
Pick names or options with custom weights — like a non-uniform raffle. See each option's true probability and draw with or without replacement.
Random
Playing Card Drawer
Draw N cards from a properly shuffled 52-card deck (optional jokers), with deck-tracking so you don't draw the same card twice.
Random
Password Generator
Generate strong, random passwords that never leave your browser.
Random
Random Number Generator
Generate cryptographically random numbers in any range — with or without duplicates, optionally sorted.
Random