Skip to content

Random numbers, dice rolls and coin flips

Roll dice like 2d6 or 4d6 drop lowest, flip coins, draw cards, spin a wheel, shuffle lists and use timers in Zlv, with rerolls and roll history on desktop.

Zlv can generate random numbers and roll dice right inside a sheet, which is handy for games, simulations and quick decisions. Random results change when you reroll them.

Random numbers

Live example
Edit the lines and press Run. Evaluated in your browser.

Evaluating…

random() returns a number between 0 and 1. random(min, max) and randint(min, max) return a value in a range.

Dice notation

Write dice the way tabletop players do: the number of dice, d, and the number of sides.

Live example
Edit the lines and press Run. Evaluated in your browser.

Evaluating…

d% is a percentile die (1 to 100). You can do arithmetic with a roll and store it in a variable:

Live example
Edit the lines and press Run. Evaluated in your browser.

Evaluating…

Advantage, disadvantage, drop and keep

Live example
Edit the lines and press Run. Evaluated in your browser.

Evaluating…

adv rolls twice and keeps the higher result; dis keeps the lower. 4d6 drop lowest is the classic way to roll a character stat. The desktop engine also supports keeping the highest dice:

Desktop example
Uses the native Rust engine: copy it into Zlv Desktop to see results.

Results appear next to each line in Zlv Desktop. Download it free.

Coins

Live example
Edit the lines and press Run. Evaluated in your browser.

Evaluating…

Games and activities

These produce an interactive result you can click.

Live example
Edit the lines and press Run. Evaluated in your browser.

Evaluating…

ExpressionWhat it does
draw(n)Draws n playing cards without replacement; reset to refill the deck
spin(a, b, ...)Spins a wheel and lands on one option
eightball("question")Gives a Magic 8-Ball answer
bag(a, b, ...)Pulls one token; repeat a token to make it more likely
shuffle(a, b, ...)Puts the options in random order
timer(duration)A countdown, such as timer(5 min)
stopwatch()Counts up from zero

Rerolls and roll history (desktop)

In the desktop app, dice and coins appear as animated badges in the results column:

  • Click a die or coin to reroll or reflip it. Lines that depend on it update.
  • Right-click a dice badge to see its roll history and the distribution of results.
  • Hover a die to see every individual die in a multi-dice roll.
  • Click a card draw, spinner, 8-ball, bag or shuffle to run it again; click a timer or stopwatch to start or pause it, and reset it to start over.
All guides