Skip to content

RANDSUM uses an extended version of standard dice notation. All notation is case-insensitive (2d8 = 2D8).

The core format is NdS where N is the number of dice and S is the number of sides.

A geometric die rolls dN repeatedly as long as the maximum face value is rolled, and the result is the sum of all rolls. All notation is case-insensitive.

NotationDescription
gNRoll dN until a non-maximum is rolled, result = sum
3gNThree independent geometric rolls

A safety cap of 1000 iterations prevents infinite loops. Use cases include resource depletion tracking, chase mechanics, and survival countdowns.

A draw die samples without replacement from a pool of faces — like drawing cards from a deck. Each face value can only appear once until the pool is exhausted, at which point it reshuffles. All notation is case-insensitive (DD, dd, Dd, dD all work).

NotationDescription
DDNDraw one unique value from [1..N]
3DDNDraw 3 unique values from [1..N]
6DD6Always a permutation of [1,2,3,4,5,6]
8DD6Full permutation of [1..6] + 2 more (reshuffles)

Use cases include card-deck mechanics, random encounter tables without repeats, draft picks, and Catan-style resource distribution.

A percentile die rolls 1-100. Used in Call of Cthulhu, Warhammer Fantasy, and any system with percentage-based resolution. All notation is case-insensitive.

ArgumentEquivalentDescription
d%roll(100)Roll one d100

d% maps internally to { quantity: 1, sides: 100 }. It does not support a quantity prefix. To roll multiple percentile dice, pass multiple arguments: roll('d%', 'd%').

d% does not support inline notation modifiers — use the options object form for modified percentile rolls.

Fate dice (also called Fudge dice) produce results of -1, 0, or +1 per die. The standard Fate Core roll is 4dF, giving a range of -4 to +4. An extended variant (dF.2) uses five faces: -2, -1, 0, +1, +2. All notation is case-insensitive.

ArgumentFacesRange per dieDescription
dF-1, 0, +1-1 to +1Standard Fate/Fudge die
dF.1-1, 0, +1-1 to +1Explicit standard variant
dF.2-2, -1, 0, +1, +2-2 to +2Extended Fudge die
4dF-1, 0, +1-4 to +4Standard Fate Core roll
4dF.2-2, -1, 0, +1, +2-8 to +8Four extended dice

Internally, dF uses the replace modifier to map die faces to negative and zero values. dF does not support inline notation modifiers — use the options object form for modified Fate rolls.

Zero-indexed dice that roll 0 to N-1 instead of 1 to N. All notation is case-insensitive.

NotationDescription
zNZero-indexed die (0 to N-1)
z6Roll 0-5 instead of 1-6
3z10Three zero-bias d10s (0-9)

Zero-bias dice are notation-only — there is no options object equivalent. Use the notation string form roll('z6') or construct faces manually: roll({ sides: [0, 1, 2, 3, 4, 5] }).

Use cases: Zero-indexed random table lookups, percentile systems that use 0-99, programming-friendly dice for array index selection.

Define dice with arbitrary face values. All notation is case-insensitive.

NotationDescription
d{2,3,5,7}Die with faces 2, 3, 5, 7
d{-1,0,1}Die with negative/zero faces
d{fire,ice,lightning}Die with string faces
3d{1,1,2}3 dice with weighted faces

Duplicate values create weighted distributions — d{1,1,2} has a 2/3 chance of rolling 1 and a 1/3 chance of rolling 2. When faces are non-numeric strings, the roll result contains string values rather than numbers.

Custom faces dice do not support inline notation modifiers — use the options object form for modified custom dice rolls.

Use cases: Custom damage type dice (fire/ice/lightning), narrative dice (success/failure/complication), weighted probability dice, or any die with non-standard faces.

Add or subtract a fixed value from the total.

NotationDescription
+NAdd N to total
-NSubtract N from total

Remove dice from the result pool.

NotationDescription
LDrop lowest 1
L2Drop lowest 2
HDrop highest 1
H2Drop highest 2
D{>N}Drop rolls over N
D{>=N}Drop rolls at or over N
D{<N}Drop rolls under N
D{<=N}Drop rolls at or under N
D{X,Y}Drop exact values X and Y

Keep specific dice from the result (complement of drop).

NotationDescription
KKeep highest 1
K3Keep highest 3
klKeep lowest 1
kl2Keep lowest 2

Limit roll values to a specific range.

NotationDescription
C{>N}Cap rolls over N to N
C{<N}Cap rolls under N to N
C{<N,>M}Cap both ends

Reroll dice matching certain conditions.

NotationDescription
R{>N}Reroll results over N
R{>=N}Reroll results at or over N
R{<N}Reroll results under N
R{<=N}Reroll results at or under N
R{X,Y}Reroll exact values X, Y
R{<N}MReroll under N, max M attempts

Replace specific results with new values.

NotationDescription
V{X=Y}Replace Xs with Y
V{>N=Y}Replace results over N with Y
V{<N=Y}Replace results under N with Y

Force all dice in a pool to show different values.

NotationDescription
UAll results must be unique
U{X,Y}Unique except X and Y can repeat

Roll additional dice when a die shows its maximum value.

NotationDescription
!Explode: one additional die per max result (single pass)

When a die shows its maximum value, it “explodes” — one new die is rolled and added to the result. This is a single pass: the newly added dice are not checked for further explosions. For recursive explosions, use compound (!!) or penetrate (!p).

Example: 3d6! rolls [6, 4, 6]. The two 6s explode, adding [5, 3]. Final result: [6, 4, 6, 5, 3] = 24.

Exploding dice that add to the triggering die instead of creating new dice.

NotationDescription
!!Compound once per die
!!NCompound with max depth N
!!0Compound unlimited (capped at 1000)

Example: 1d6!! rolls 6. This compounds, rolling 4. The die value becomes 6 + 4 = 10. Unlike regular exploding, this does not create new dice — it modifies the existing die.

Difference from explode:

  • Explode (!): Creates new dice — [6, 4, 6] becomes [6, 4, 6, 5, 3] (5 dice)
  • Compound (!!): Modifies existing die — [6, 4, 6] becomes [15, 4, 12] (still 3 dice)

Exploding dice where each subsequent explosion subtracts 1 (Hackmaster-style).

NotationDescription
!pPenetrate once per die
!pNPenetrate with max depth N
!p0Penetrate unlimited (capped at 1000)

Example: 1d6!p rolls 6. This penetrates, rolling 5. The value added is 5 - 1 = 4, so the die becomes 6 + 4 = 10.

The D6 System wild die modifier (West End Games). The last die in the pool is designated as the “wild die” with special behavior. All notation is case-insensitive.

NotationDescription
WLast die is the “wild die”

Wild die behavior:

  • Wild die = max value (6): The wild die compound-explodes — keep rolling and adding while the maximum is rolled.
  • Wild die = 1: Remove the wild die AND the highest non-wild die from the pool.
  • Otherwise: No special effect, the wild die acts as a normal die.

Example: 5d6W rolls [4, 3, 5, 2, 6]. The wild die (6) compound-explodes: rolls 4, so wild die becomes 10. Result: [4, 3, 5, 2, 10] = 24.

Example (wild 1): 5d6W rolls [4, 3, 5, 2, 1]. The wild die (1) triggers removal: remove the 1 (wild) and the 5 (highest non-wild). Result: [4, 3, 2] = 9.

Multiply the dice sum before adding/subtracting arithmetic modifiers.

NotationDescription
*NMultiply dice sum by N

Example: 2d6*2+3 rolls [4, 5] = 9. Multiplied by 2 = 18. Plus 3 = 21.

Count dice meeting a threshold instead of summing values. Used in dice pool systems.

NotationDescription
S{N}Count dice >= N
S{N,B}Count successes >= N, subtract botches <= B

Example: 5d10S{7} rolls [8, 3, 10, 6, 9]. Successes >= 7: [8, 10, 9] = 3 successes.

Count how many dice rolled at or below a threshold. The total becomes the failure count. All notation is case-insensitive.

NotationDescription
F{N}Count dice that rolled <= N

Example: 5d10F{3} rolls [8, 2, 10, 1, 9]. Failures <= 3: [2, 1] = 2 failures.

Sort dice results for display purposes without changing the total. All notation is case-insensitive.

NotationDescription
saSort ascending
sdSort descending

Sort reorders the dice results for display without changing the total. Useful for readability when reviewing large pools.

Integer divide the total, truncating toward zero. All notation is case-insensitive.

NotationDescription
//NInteger divide total by N (truncates via Math.trunc)

Example: 4d6//2 rolls [3, 5, 4, 2] = 14. Integer divided by 2 = 7.

Use cases: Halving damage (e.g., resistance in D&D), averaging mechanics, systems that use integer math for resource calculation.

Apply modulo to the total. All notation is case-insensitive.

NotationDescription
%NTotal modulo N

Example: 4d6%3 rolls [3, 5, 4, 2] = 14. 14 % 3 = 2.

Use cases: Wrapping values into ranges, clock mechanics, cyclic resource systems.

Multiply the entire final total after all other modifiers.

NotationDescription
**NMultiply final total by N

Difference from pre-arithmetic multiplier:

  • Pre-arithmetic (*): 2d6*2+3 = (sum x 2) + 3
  • Total (**): 2d6+3**2 = (sum + 3) x 2

Notation sugar that repeats a roll expression N times. All notation is case-insensitive.

NotationDescription
xNRepeat the preceding notation N times

The xN suffix is detected during notation parsing. It strips the suffix, then repeats the base notation N times as separate roll groups. N must be >= 1.

Example: 4d6Lx6 expands to six separate 4d6L rolls — perfect for generating all six D&D ability scores in a single call.

Use cases: D&D ability score generation (4d6Lx6), rolling multiple identical damage dice groups, batch stat generation.

Attach metadata labels to dice terms. Labels are flavor text with no mechanical effect. All notation is case-insensitive.

NotationDescription
[text]Label attached to a roll group
2d6+3[fire]+1d4[cold]Labels on specific dice groups

Labels are enclosed in square brackets and attached to the preceding dice term. They are stripped before modifier parsing and stored in the roll result. Labels are valid notation — isDiceNotation accepts notation with labels.

Use cases: Tracking damage types in D&D, labeling ability score rolls, annotating complex multi-group rolls for display purposes.

Modifiers can be chained together. They are applied in a fixed priority order:

PriorityModifierNotationDescription
10CapC{...}Limit roll values to a range
30ReplaceV{...}Replace specific values
40RerollR{...}Reroll dice matching conditions
50Explode!Roll additional dice on max
51Compound!!Add explosion to existing die
52Penetrate!pAdd explosion minus 1 to die
60UniqueUEnsure no duplicate values
65DropH, LRemove dice from pool
66KeepK, klKeep dice in pool
70Explode Sequence!s{...}, !i, !rExplode through die size sequence
75Wild DieWD6 System wild die behavior
80Count SuccessesS{...}Count dice meeting threshold
80Count FailuresF{...}Count dice at or below threshold
95Sortsa/sdSort results for display
100Multiply*NMultiply dice sum (pre-arithmetic)
110Plus+NAdd to total
111Minus-NSubtract from total
120Integer Divide//NInteger divide total
130Modulo%NTotal modulo N
150Total Multiply**NMultiply entire final total

Roll different dice types in a single expression:

import { roll } from '@randsum/roller'
// Attack roll + damage
roll('1d20+5', '2d6+3')
// Subtract a die group
roll('2d12-1d6') // Roll 2d12, subtract 1d6