Dice Core notation

Complete map of the grammar, shortcuts, and pages for every roll type.

Choose a roll type

Every topic below has detailed rules and examples that open directly in the playground.

Fundamentals Modifiers Advanced and systems
Numeric, percentile, and Fudge dice Keep and drop Groups
Arithmetic and functions Reroll and unique Multiple rolls and comments
Comparisons on this page Explosions Mixed batches
Targets and criticals Fate
Min, max, and sort Vampire V5
Pool, adv, and dis Assimilation
Step Daggerheart

Expression shape

NdX rolls N dice with X sides; operators and functions build expressions. Modifiers are die suffixes: 4d6kh3. A braced list forms a group: {d8,d10}kh1. N# repeats one formula; ; splits a mixed batch, including special systems. Compact notation is conventional, but input may contain whitespace.

2d20+5
4d6kh3
{d8,d10}kh1
2#d20+5
d20+5; v5(7,3,4)

Compare points

Conditional modifiers accept =, !=/<>, <, <=, >, and >= followed by a numeric literal, signed if needed. r<3 rerolls 1 or 2 on d20; !>=5 explodes on 5 or 6 on d6; >=8f=1 counts successes and failures. Immediately after a die, ! starts an explosion, so d6!=3 means “explode on 3”; for a “not equal to 3” target use d6<>3.

Normalization shortcuts

d becomes d20; f becomes 4dF; 2f becomes 2dF; ei6 becomes !>=6; km becomes kl1; k becomes k1. -pool(N) becomes pool(-N), while +step(N) becomes step(+N). normalizeRpgDiceNotation() returns normalized text; inspectRpgDiceNotation() validates without consuming RNG.

import { normalizeRpgDiceNotation, inspectRpgDiceNotation } from '@erpg/dicecore/core'
console.log(normalizeRpgDiceNotation('d + 2f')) // d20+2dF
console.log(inspectRpgDiceNotation('4d6kh3').isValid) // true

Runtime modifiers follow a fixed order: min, max, explode, reroll, unique, keep, drop, target, critical success, critical failure, and sort. Structural pool, adv, dis, and step resolve first. If a modifier kind appears more than once, the last one wins.

Try the examples

Try 4d6kh3 · Try d6!2>=5 · Try d20+5;v5(7,3,4)