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.
Click Flip to begin.
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.
- 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-sidevalidatedflip · text1x · setFlipping…
loaded · parsedclient-side - 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.
faceoptionslivememoisedtogglesout · memoisedH/T · liveHeads
options set · memoisedlive - 03
Track the balance
Heads and tails counters update so you can spot streaks.
Randomness — where used — comes from
crypto.getRandomValues, neverMath.random. Heavy work sits inuseMemo.statscomputeinstantlocaldeterministicstats · instantlive · computedH 7 / T 5
computed · instantinstant - 04
Reset whenever
Clear wipes the history without affecting the next flip.
Copy writes through
navigator.clipboardand downloads use aBlob— zero network traffic. Same input plus same options always yield the same bytes.resetcopydownloadzero-networkreproducibleok · copiedfresh · copiedCleared
shipped · ready to shipsuccess
Pro tips for everyday utilities
Reach for crypto.getRandomValues
Cryptographically random for IDs, tokens, salts. Math.random is for animation and games, not security.
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.
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-backedStand-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.
reproducibleA/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.
snappyGame 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-detectedStreak 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.
deterministicEducation
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-readyFrequently asked questions
Something missing?
Tell us what you need. We ship the top requests every two weeks.