PK Systems PK Systems
Generators

Coin Flip and Dice Roller

Heads or tails, D6, D20, 2D6 or any custom die — animated, fair, with a roll history.

Coin Flip and Dice Roller

H
T

Result

What this tool does

Replaces the physical coin or die you don't have on hand. Pick a coin (heads or tails), a single D6 or D20, two D6 (with the sum), or any custom die from 3 to 100 sides. The coin flip is a 3D CSS rotation of an actual gold-and-blue coin; dice shake briefly before settling on a value. Randomness is crypto-grade — we use crypto.getRandomValues() with rejection sampling to remove the modulo bias that Math.random() % n introduces on uneven ranges. Every result lands in a history strip showing the last ten rolls, so you can prove a contested call. Useful for tabletop games, classroom decisions, sport-fixture coin tosses, splitting bills, or settling "who has to take the bins out" without rooting through a drawer for a quarter.

How to use it

Pick a die type — coin, D6, D20, 2D6 or custom. For custom, type the side count (3 to 100). Hit the big button: the coin spins on its 3D axis or the dice shake on the spot. The result lands in the panel below with the value highlighted, and gets pushed to the history strip. Switch types and roll again — each roll is independent. The history holds the last ten rolls; older ones drop off.

How the randomness works

Naive code like Math.floor(Math.random() * sides) looks random but introduces modulo bias when sides doesn't divide 2^32 evenly — some values come up slightly more often. We avoid that by sampling a 32-bit integer from crypto.getRandomValues() and rejecting any draw above floor(2^32 / sides) * sides, then taking the rejection-free draw modulo sides. The result is mathematically uniform: a fair D7 truly produces 1-7 with equal odds. The coin animation runs a CSS rotateY across multiple half-turns plus the final 0° or 180° depending on the result; the dice use a brief shake animation before revealing the chosen face.

Die types and ranges

All types use the same unbiased crypto RNG — only the visual differs.

Type Range Use
CoinH or TCoin tosses, yes/no, sport draws
D61–6Standard board games
2D62–12RPGs, settlers, monopoly
D201–20D&D, percentile-style rolls
Custom3–100Custom games, statistics demos

Frequently asked questions

Is the dice really fair?
Yes. We use crypto.getRandomValues() with rejection sampling, which is mathematically uniform. A D7 hits each face with exactly 1/7 probability — no "the 6 always wins" bias.
Why does the coin flip take a second?
The animation is purely visual; the actual result is decided instantly. We let the rotation play for ~1.4 s so it feels like a real flip, but the answer is locked the moment you click.
Can I roll multiple dice?
Pick 2D6 to roll two D6 with the sum displayed. For more complex rolls (3D8, advantage rolls), the custom die plus history strip lets you stack quick rolls — but a dedicated DnD dice app may be a better fit for full RPG sessions.
What's the maximum custom die?
100 sides. Beyond that, our regular Random Number Generator tool is a better fit since you typically want a range and count rather than a die.
Does it remember my rolls?
Only in this tab, only the last 10. Closing the tab clears the history. Nothing is saved to disk or sent to a server.
Can I use it for legal raffles?
Technically yes — the RNG is verifiably uniform. But legal raffles usually require an audit trail that this tool doesn't produce. For a one-off office raffle, perfect; for a regulated draw, use an authority-certified service.