DevTools Logo
All posts

Picking a Random Number (or a Raffle Winner) Without a Server

August 28, 2026 · DevTools

random-number
raffle
giveaway
crypto

Picking "a random number between 1 and N" sounds trivial until you're running a giveaway and someone asks how it was generated. The Random Number & Raffle Picker draws from crypto.getRandomValues() rather than Math.random(), and handles the range and uniqueness edge cases that naive implementations get wrong.

The modulo bias trap

A common shortcut — random() % range — introduces a subtle bias when the range doesn't evenly divide the generator's output space: some numbers become slightly more likely than others. The tool sidesteps this by generating a uniform float in [0, 1) from crypto-strength randomness first, then scaling it into the requested integer range, rather than taking a modulo of a fixed-width random integer.

Raffle mode: an unbiased single draw

Paste your entries and each "Pick" click runs a Fisher-Yates shuffle over the full list using the same crypto-backed random source, then takes the entry that lands first — every name gets an equal, independently-verifiable chance on that draw. It re-shuffles fresh each click rather than tracking who already won, so if you're drawing several winners in a row, remove each winner from the textarea before the next pick to guarantee no repeats.

When you actually need an audit trail

For a real-money or legally-binding drawing, screen-record the draw or export the shuffled order — this tool proves nothing about when a number was generated, only that the algorithm underneath is a sound one. For dice-specific rolls with notation like 2d6+3, use the 3D Dice Roller & Coin Flip; for choosing between named options visually, the Decision Wheel & Picker spins through the same shuffle logic.