fair · 50/50 · history · local

Flip a virtual coin

A simple heads-or-tails decider backed by the Web Crypto RNG. Track the last twenty flips and watch the totals balance out.

Coin Flip
Result
—
—
Heads
0
—
Tails
0
—
Flips
0
last 20
input · coin
?
—
output · history (0)

Click Flip to begin.

Quick Start

How to flip a coin

The coin uses crypto.getRandomValues for a cryptographically fair 50/50 decision. The visual delay is purely cosmetic — the result is decided when you click.

  1. 01

    Click Flip

    One click runs one flip and adds it to the history.

    Inputs are treated as UTF-8 throughout the pipeline and validated client-side as you type — nothing dispatches until the value is well-formed.

    flipinpututf-8client-sidevalidated
    flip · text1x · set
    Flipping…
    loaded · parsedclient-side
  2. 02

    Read the face

    Heads or tails is announced above the coin and stored in history.

    Each toggle re-computes through a memoised hook, so flipping options never resets your input and the UI stays snappy on large inputs.

    faceoptionslivememoisedtoggles
    out · memoisedH/T · live
    Heads
    options set · memoisedlive
  3. 03

    Track the balance

    Heads and tails counters update so you can spot streaks.

    Randomness — where used — comes from crypto.getRandomValues, never Math.random. Heavy work sits in useMemo.

    statscomputeinstantlocaldeterministic
    stats · instantlive · computed
    H 7 / T 5
    computed · instantinstant
  4. 04

    Reset whenever

    Clear wipes the history without affecting the next flip.

    Copy writes through navigator.clipboard and downloads use a Blob — zero network traffic. Same input plus same options always yield the same bytes.

    resetcopydownloadzero-networkreproducible
    ok · copiedfresh · copied
    Cleared
    shipped · ready to shipsuccess
Pro tips

Pro tips for everyday utilities

Reach for crypto.getRandomValues

Cryptographically random for IDs, tokens, salts. Math.random is for animation and games, not security.

Sort IDs lexicographically

UUID v4 has no time ordering. Use ULID or UUID v7 if you need sorted IDs.

Mock data with seeds

Faker-style libraries can be seeded so tests are reproducible. Embed the seed in the fixture file.

Reference cards beat memory

Cheatsheets for Vim, Git, Docker, Linux signals are faster than man pages when you’re mid-flow.

Browser APIs vary

Touch events, gamepads, and clipboard differ across vendors. Feature-detect before use.

Persist in the right place

localStorage for user preferences, sessionStorage for transient state, IndexedDB for structured data.

Use Cases

When to flip a coin

Tiebreakers, draft order, randomised tests.

Quick decisions

Pizza or pasta? Let the coin decide. Random values come from crypto.getRandomValues — cryptographically secure for tokens, salts, and session IDs. Math.random is deterministic enough for animations but predictable enough to be a security bug.

CSPRNG-backed

Stand-up tiebreaker

Who demos first in the next sprint review. Pair with hashids, ULID, or UUID v7 when you need both random and sortable — useful for primary keys, public-facing IDs, and event log ordering without a sequence column.

reproducible

A/B routing

Coin-flip a manual user into Variant A or B. Output is deterministic given the same seed, so fixtures and tests stay reproducible across CI runs and contributor machines. Embed the seed in the fixture file for full replay.

snappy

Game prototypes

Wire a manual coin into your tabletop playtest. Heavy work runs through useMemo so the UI stays snappy on large inputs. Same input + same options yields identical bytes — the kind of stability snapshot tests rely on.

feature-detected

Streak observation

Watch the gambler's fallacy in real time. Storage tools persist to the right backend: localStorage for user preferences, sessionStorage for transient state, IndexedDB for structured data. Pick the right shelf and quota worries disappear.

deterministic

Education

Teach probability with a tangible 50/50. Browser feature detection: clipboard, fullscreen, gamepad, and Web Bluetooth APIs gracefully fall back when unavailable. No surprise white screens on Safari or older Firefox.

production-ready
FAQ

Frequently asked questions

Yes — we use crypto.getRandomValues to pick a uniformly random bit. There is no biased weighting in either direction.
The 700ms spin is a CSS animation. The result is decided up front and committed when the animation ends.
Use the Dice Roller for batch random outcomes, or just hammer the Flip button — every flip is independent.
The last twenty flips. Clear resets it instantly.
No. The coin and history run entirely in your browser.
Suggest a tool

Something missing?

Tell us what you need. We ship the top requests every two weeks.

Sent straight to the maintainers · no account needed
47 in queue·8 shipped this month
Request queued. Thanks!