D20 Dice Roller Calculator
Roll d20 dice with modifiers, advantage, and disadvantage. Cryptographic RNG, full roll history, and statistical analysis for D&D and tabletop RPGs.
About
Tabletop RPG outcomes hinge on the d20 roll. A miscounted modifier or a forgotten advantage condition can invalidate an entire combat round. This calculator uses crypto.getRandomValues() with rejection sampling to produce uniform distribution across 1 - 20, eliminating modulo bias that plagues naive Math.random() implementations. It supports multi-die pools up to 100d20, signed modifiers from −999 to +999, and D&D 5e Advantage/Disadvantage mechanics. Roll history persists across sessions for audit trails during long campaigns.
The expected value of a single d20 is 10.5. For n dice with modifier m, expected total equals n × 10.5 + m. Advantage shifts the single-die expected value to approximately 13.825. Disadvantage drops it to roughly 7.175. This tool computes these statistics in real time. Note: this tool approximates a perfectly fair icosahedron. Physical dice with manufacturing defects will deviate from theoretical distributions.
Formulas
The total result of a dice roll with n dice and modifier m is computed as:
where each ri ∈ {1, 2, …, 20} is drawn from a uniform discrete distribution.
Expected value for a single d20:
Standard deviation for n dice:
For Advantage (rolling 2d20, keeping the highest):
For Disadvantage (keeping the lowest):
Rejection sampling ensures uniform distribution: a random byte from crypto.getRandomValues() in range 0 - 255 is accepted only if < 240 (largest multiple of 20), then mapped via r = (byte mod 20) + 1.
Where: n = number of dice, m = modifier (signed integer), ri = individual die result, σ = standard deviation.
Reference Data
| Roll Mode | Dice Expression | Min | Max | Expected Value | Std Dev (σ) | P(Natural 20) | P(Natural 1) | Common Use |
|---|---|---|---|---|---|---|---|---|
| Standard | 1d20 | 1 | 20 | 10.50 | 5.77 | 5.00% | 5.00% | Attack rolls, ability checks |
| Advantage | 2d20 keep highest | 1 | 20 | 13.83 | 4.72 | 9.75% | 0.25% | Flanking, Reckless Attack |
| Disadvantage | 2d20 keep lowest | 1 | 20 | 7.18 | 4.72 | 0.25% | 9.75% | Dodge, Poisoned condition |
| Standard | 2d20 | 2 | 40 | 21.00 | 8.16 | N/A (sum) | N/A (sum) | Dual rolls, group checks |
| Standard | 1d20+5 | 6 | 25 | 15.50 | 5.77 | 5.00% | 5.00% | Level 5 fighter attack |
| Standard | 1d20−2 | −1 | 18 | 8.50 | 5.77 | 5.00% | 5.00% | Low ability modifier |
| Standard | 3d20 | 3 | 60 | 31.50 | 9.99 | N/A (sum) | N/A (sum) | Multi-attack totals |
| Standard | 4d20 | 4 | 80 | 42.00 | 11.55 | N/A (sum) | N/A (sum) | Mass roll pools |
| Advantage | 2d20kh+3 | 4 | 23 | 16.83 | 4.72 | 9.75% | 0.25% | Advantage + modifier |
| Disadvantage | 2d20kl+3 | 4 | 23 | 10.18 | 4.72 | 0.25% | 9.75% | Disadvantage + modifier |
| Standard | 1d20 (DC 15) | 1 | 20 | 10.50 | 5.77 | 30% pass | 70% fail | Medium difficulty check |
| Standard | 1d20 (DC 10) | 1 | 20 | 10.50 | 5.77 | 55% pass | 45% fail | Easy difficulty check |
| Standard | 1d20 (DC 20) | 1 | 20 | 10.50 | 5.77 | 5% pass | 95% fail | Hard difficulty check |
| Advantage | Adv (DC 15) | 1 | 20 | 13.83 | 4.72 | 51% pass | 49% fail | Adv on medium DC |
| Disadvantage | Disadv (DC 15) | 1 | 20 | 7.18 | 4.72 | 9% pass | 91% fail | Disadv on medium DC |