How The Hat Draw works
Exactly what happens between pasting names and seeing a winner, taken from the code that runs the draw.
1. Your list stays on this device
The Hat Draw is a single web page. When you type or paste names, they live in the page in your browser. The draw runs in JavaScript on your computer or phone; no list of entrants is uploaded to a server to make the pick. To protect against an accidental refresh, the page saves a draft (event title, entries, options and any winners drawn so far) in your browser’s localStorage on that device only. Pressing Start over clears that draft.
2. Reading the list
Entries are split on new lines, commas or semicolons. Extra spaces are collapsed and blank lines are dropped, so “Jordan Hale, Priya Nair” and two separate lines produce the same two entries. The counter above the box shows how many entries are in the hat.
3. Duplicates
With Remove duplicates off, every line is its own chance, so a person who bought three tickets can be listed three times. With it on, names are compared without regard to capitalization and only one copy of each is kept, so every unique name has exactly one chance.
4. The random source
Random numbers come from crypto.getRandomValues, the browser’s cryptographically secure random number generator, rather than the general-purpose Math.random. To turn a 32-bit random value into a position between 0 and n−1 without bias, the code throws away the few values at the very top of the range that would make some positions slightly more likely (rejection sampling), and then takes the remainder. Every position is exactly equally likely.
5. The Fisher–Yates shuffle
The whole list is shuffled with the Fisher–Yates algorithm: starting at the last entry and working toward the first, each entry is swapped with a randomly chosen entry at or before its position. This produces every possible ordering with equal probability. Winners are taken from the front of the shuffled list and removed from the hat, so a single entry cannot win twice; the names left behind form the pool for the next pick.
The rolling names you see in the shuffle animation are just for show; the winner has already been chosen by the shuffle when the animation starts.
6. Drawing more names
Choose how many winners to draw at once. After a draw, Draw Next Name reshuffles the remaining names and adds the next place. Once a draw starts, options that would change the odds (winner count, duplicates, reverse) are locked until you start over.
7. Reverse reveal: last place first
Turn on Build suspense: reveal last place first and the draw goes one name at a time from the bottom up. With 12 names, the first name drawn is 12th place, then 11th, and so on until 1st place is revealed last. Each pick takes the worst remaining place, so the whole hat is ranked by the end. The list on screen always reads from best place to worst, so 11th appears above 12th as names arrive.
8. Sharing, copying and printing
- Copy results link creates a URL whose hash (the part after
#) contains only the event title, whether reverse reveal was used, and the winners with their places. It does not include the rest of the entry list. Because it is in the hash, browsers do not send it to the web server when the page loads. - Copy names copies a plain-text winner list for chat or email.
- Print produces a clean sheet with the title and every winner, across several pages if needed.
9. Start over
Start over empties the hat, clears the winners, resets the options and deletes the saved draft from localStorage. On a shared or projector computer, press it when you are done.
What The Hat Draw does not do
It does not sell tickets, take payments, check who is eligible, or keep a record on a server. It is not a lottery or wagering service. For planning and record keeping around the draw, see the guides, especially fair drawing methods.
Last updated 10 October 2026.