3D Dice Roller

Dice that tumble, land, and tell the truth.

  • d4 to d20
  • Physics, fair rolls
  • Works offline
Seven colored six-sided dice at rest on grey felt inside a square wooden dice tray on a wooden table, lit warmly from one side.

The guide

A die is fair by symmetry. A computer has to throw numbers away to match it.

Five ancient solids, one kite-faced outsider and a rule about opposite faces explain the dice on the table, while the dice on a screen need a different kind of care.

  • 5 + 13 + 2 regular solids, other single shapes and endless classes of fair dice
  • 0.750 inch smallest side New Jersey allows on a casino die
  • 43 in 256 share of each of four faces when a byte is reduced mod 6
  • 13.825 mean of the higher of two d20, against 10.5 for one
  • 9.75% chance of a 20 with advantage, up from 5%
Read the full guide Fold the guide 8 min · 18 sources

Nobody inspects a die before trusting it. We pick it up, shake it, and accept whatever lands, which is a remarkable amount of faith to place in a small lump of plastic.

That faith rests on two separate things, and they are easy to confuse. One is the shape: a die is built so that no face has any reason to come up more often than another. The other is the throw, which has to be messy enough that nobody can steer it. A screen changes both. The shape becomes arithmetic and the throw becomes a random number generator, and each has its own way of going quietly wrong.

The shape does the work

Mathematicians have an exact word for a fair shape. An isohedron is a convex solid whose symmetries can carry any face onto any other, so that the faces differ in name only. Persi Diaconis and Joseph Keller called such a die fair by symmetry in 1989. By their count, every one takes the form of a regular solid, of which there are five, or of one of thirteen other individual shapes, or of a member of two endless classes.

The famous members are the Platonic solids, each built from identical regular polygons. There are exactly five of them: the tetrahedron with 4 faces, the cube with 6, the octahedron with 8, the dodecahedron with 12 and the icosahedron with 20. Those five are the d4, d6, d8, d12 and d20 of a role-playing set. Count again and something is missing. The set also holds a ten-sided die, and no Platonic solid has ten faces.

The d10 is the odd one out, a pentagonal trapezohedron. Its ten faces are kites rather than regular polygons, five meeting at a point on top and five at a point underneath, interleaved around the middle. It belongs to one of two endless families of isohedra, the trapezohedra and the dipyramids, in which the number of faces can be varied. The family is less exotic than it sounds. Stand a cube on one corner so that the opposite corner points straight up, and it is a trapezohedron too, with three faces around each end.

One rule limits every member. An isohedron always has an even number of faces, so no shape is fair by symmetry with seven sides, or with five. A seven-sided die has to cheat a little: the tool on this page, asked for a d7, builds a fourteen-faced trapezohedron and prints each number twice.

Symmetry on paper is not symmetry in the hand. New Jersey’s casino regulations show how much effort a real cube takes. Each die must be a perfect cube no smaller than 0.750 inch on a side, transparent, with flat faces, square edges and its weight equally distributed. Even the spots are regulated: they must sit flush with the surface, and each must extend into the cube exactly as far as every other, to a tolerance of .0004 of an inch. Precision dice have their drilled pips filled with paint or epoxy that matches the density of the body, which keeps the die balanced.

What is printed where

Numbering follows rules of its own. On a six-sided die opposite faces add up to seven, a tradition firm enough to be written into law: the New Jersey text spells out that one sits opposite six, two opposite five and three opposite four. That still leaves two mirror-image dice, depending on whether one, two and three run clockwise or counterclockwise around the corner they share. Western dice are normally the counterclockwise, right-handed kind. Chinese dice are normally the other.

The other dice usually extend the pattern. Opposite faces add up to one more than the number of faces, so a twenty-sided die pairs 1 with 20 and 2 with 19. The four-sided die cannot play along, because a tetrahedron resting on a face has a corner on top and no face at all. Some d4s solve it by printing the same number near each corner on every face that meets there, and the corner pointing up gives the result.

The ten-sided die is usually numbered 0 to 9, and the 0 can be read as ten. Two of them make percentile dice, one of the pair marked in tens from 00 to 90. Add them for a number from 0 to 99, except that 00 with 0 is typically read as 100. That pair is the common way to roll a d100, even though hundred-sided dice exist.

A die made of numbers

A program has no shape to lean on. It has a generator, and generators come in two grades. JavaScript’s Math.random returns a number from 0 up to 1 with an approximately uniform spread, from a seed the program cannot choose. In the V8 engine it is an algorithm called xorshift128+, with 128 bits of internal state and a period of 2^128 - 1, and V8’s own engineers say plainly that it is still not cryptographically secure. That matters little for a game of patience. It matters when someone could profit from guessing the next number.

The stronger grade is the browser’s crypto.getRandomValues, which fills an array with cryptographically strong random values. It is not magic either. Mozilla’s documentation notes that implementations use a pseudo-random generator seeded with a value that has enough entropy, and the W3C specification asks for a well-established cryptographic generator fed from a high-quality source such as the operating system’s. The difference lies in what it is designed to resist: someone studying its past output in order to work out the rest.

Even perfect random bits can be spoiled in the last step. Take one random byte, a number from 0 to 255, and turn it into a die face by taking the remainder after dividing by six. The byte has 256 values, and 256 is not a multiple of six, so four of the faces each receive 43 in 256 of the outcomes and the other two receive 42. The die now leans toward four of its faces by a little over two percent, invisibly, on every roll. The OpenBSD manual names the fault modulo bias and steers programmers away from taking a remainder whenever the range is not a power of two.

The cure is to throw numbers away. In what the standards institute NIST calls the simple discard method, a six-sided die takes three random bits, which make a number from 0 to 7. A result of 6 or 7 is discarded and three fresh bits are drawn; anything else is the roll. NIST states that the method produces a number with no skew. The price is waste, since a quarter of the draws for a d6 go in the bin. Programming languages ship library functions for this one job because doing it without bias takes care, and the tool on this page pays the same price for every die it rolls.

How would anyone know? The standard check is the chi-square goodness-of-fit test. Roll a die 600 times and a fair one should show each face about 100 times. For each face, square the gap between the observed count and the expected one, divide by the expected count, and add the six results. A fair six-sided die produces a total above 20.515 only about one time in a thousand, so a larger number is strong evidence of a fault. A small number proves less than it seems. The test can catch a die that is unfair in the way it measures. It can never certify one as fair.

Notation, and what advantage is worth

Tabletop players write rolls in a compact notation. In nds, s is the number of sides and n the number of dice to roll and add, so 3d8 + 5 is three eight-sided dice summed, plus 5. Virtual tabletops have grown suffixes for the common tricks. In Foundry’s dialect kh keeps the highest dice, kl keeps the lowest and dl drops the lowest, which makes 4d6dl1 the same roll as 4d6kh3.

The best known of those suffixes encodes a rule from Dungeons & Dragons. A roll with Advantage means rolling a second d20 and using the higher of the two; with Disadvantage, the lower. In notation that is 2d20kh1 and 2d20kl1.

The effect is easy to work out and easy to check. A single d20 averages 10.5. For the higher of two, the chance that both dice show k or less is k squared over 400, and summing over the twenty faces gives a mean of 13.825, a gain of 3.325. Type 2d20kh1 into the tool above, or press Advantage, then run the 10,000 rolls. The expected mean reads 13.825, and the measured mean lands within about a tenth of it, a little different every time.

The average hides the shape, though. Advantage is not a flat bonus of three and a bit. Needing an 11 or better, a plain d20 succeeds half the time and an advantaged one three times in four, which is worth as much as adding 5 to the roll. Needing a 20, the chance rises only from 5% to 9.75%. The largest change is at the bottom, where a roll of 1 goes from one chance in 20 to one in 400. Advantage does little for long shots and a great deal against disaster.

What a simulation leaves out

A dice roller of this kind makes one promise, and it is narrower than the tumbling suggests. The numbers are drawn first, from the secure generator, and the animation is then arranged to end on them. The simulated bounce is there to be watched, not trusted, because a throw computed in floating-point arithmetic is exactly the kind of process that could hide a bias nobody intended.

It cannot tell you anything about the dice in your bag. Your own die is a physical object, and only rolling it many times and counting, as in the test above, will show whether it has quirks. Nor is the screen’s randomness the same thing as chance at a table. It is a deterministic generator started from a seed with enough entropy, which is as much as software can offer, and no single roll can be shown to be fair by itself. Fairness is a property of long runs.

So the old arrangement survives the move to glass. Trust the shape, or the arithmetic that stands in for it. Then let the throw be something nobody controls.

Sources

Every source consulted for this guide. Links checked October 7, 2026.

  1. Fair Dice OpenAlex catalogue record W4252063291 (Persi Diaconis and Joseph B. Keller, American Mathematical Monthly, vol. 96, no. 4, 1989)
  2. Isohedral figure - Wikipedia Wikipedia
  3. Platonic solid - Wikipedia Wikipedia
  4. Trapezohedron - Wikipedia Wikipedia
  5. Pentagonal trapezohedron - Wikipedia Wikipedia
  6. Dice - Wikipedia Wikipedia
  7. Chapter 69E, Gaming Equipment (N.J.A.C. 13:69E-1.15, Dice; physical characteristics) New Jersey Division of Gaming Enforcement, Office of the Attorney General
  8. Crypto: getRandomValues() method MDN Web Docs (Mozilla)
  9. Web Cryptography Level 2 World Wide Web Consortium (W3C)
  10. Math.random() MDN Web Docs (Mozilla)
  11. There's Math.random(), and then there's Math.random() Yang Guo, V8 project blog
  12. Recommendation for Random Number Generation Using Deterministic Random Bit Generators National Institute of Standards and Technology, Special Publication 800-90A Revision 1 (Barker and Kelsey, 2015)
  13. arc4random(3) - OpenBSD manual pages OpenBSD
  14. Fast Random Integer Generation in an Interval Daniel Lemire, ACM Transactions on Modeling and Computer Simulation 29(1), 2019 (arXiv copy)
  15. Chi-Square Goodness-of-Fit Test NIST/SEMATECH e-Handbook of Statistical Methods, section 1.3.5.15
  16. Critical Values of the Chi-Square Distribution NIST/SEMATECH e-Handbook of Statistical Methods, section 1.3.6.7.4
  17. Dice Modifiers Foundry Virtual Tabletop
  18. System Reference Document 5.2.1 Wizards of the Coast LLC (CC BY 4.0)