LetsColab

Secret Santa generator

Enter everyone taking part, add anyone who should not draw each other, and draw. Then send each person a link that reveals only their own match, so even the organiser can join in.

Example draw (the page’s built-in example, not yours)

All pairs
  • Alex → Fatima
  • Bea → Carlos
  • Carlos → Eli
  • Dana → Alex
  • Eli → Bea
  • Fatima → Dana

The setup link contains the names, exclusions and note, but no draw. Use it to let a co-organiser run the draw.

Why pulling names from a hat goes wrong

The number of ways n people can draw with nobody getting themselves (derangements), and the share of honest hat draws that come out valid at the first attempt.

People Valid assignments Hat draws with no self-match
3 2 33.3%
4 9 37.5%
5 44 36.7%
6 265 36.8%
8 14,833 36.8%
10 1,334,961 36.8%
12 176,214,841 36.8%

How the draw works

A Secret Santa draw is a shuffle with rules: every person gives exactly one gift and receives exactly one, nobody draws their own name, and nobody draws someone they have been excluded from. The generator uses rejection sampling. It shuffles the list of receivers with the Fisher–Yates algorithm, using random numbers from crypto.getRandomValues (the browser’s cryptographically secure generator), and checks the result against every rule. If any rule is broken, the whole draw is discarded and a fresh one is made. The first draw that passes is used.

Discarding whole draws, rather than patching them, is what keeps it fair. Every assignment that satisfies the rules is exactly as likely as every other. With no exclusions, a random shuffle has no self-matches about 37% of the time (the table shows why), so a valid draw typically turns up within a handful of attempts. If the rules are so tight that 20,000 random draws all fail, the generator switches to a randomised search that tries every possibility in a random order. That search always finds a valid assignment if one exists, and if none does it says so plainly.

The problem with the hat

The table’s last column is the number of derangements divided by all possible orderings. It settles close to 1/e ≈ 36.8% almost immediately, which means that nearly two out of three honest hat draws have at least one person holding their own name. Groups usually fix that by letting the unlucky person draw again, but that is not fair: it changes the odds for everyone still to draw, and the last person can be left holding only their own name with nobody to swap with. With couples to keep apart, the hat becomes unworkable.

A worked example

Six people take part: Alex, Bea, Carlos, Dana, Eli and Fatima. Alex and Bea are a couple, and so are Carlos and Dana. With “both ways” ticked, that rules out four pairings: Alex to Bea, Bea to Alex, Carlos to Dana and Dana to Carlos. Of the 265 ways six people can draw without anyone getting themselves, those rules remove some, and the generator picks one of the remaining assignments uniformly at random. The example above is one such draw.

After drawing, press “Copy link” next to each name and send it to that person privately, by email or direct message. When they open it they see a greeting and a button; pressing it shows who they are buying for, plus your note about budget and date. Close the pairs list before sharing your screen.

Where it stops being useful

The page keeps nothing. If you close it after drawing, the draw is gone except in the links you already sent, so copy every link before you leave, or redraw and resend. The private links are encoded, not encrypted: they stop someone reading a match over a shoulder, but anyone who has the link and decodes it can read it. The generator also cannot send messages or emails for you; that is deliberate, since sending would mean collecting addresses on a server.

Common questions

How does the Secret Santa generator make sure nobody gets themselves?

It draws a completely random assignment, checks it against the rules (nobody gives to themselves, nobody gives to anyone on their exclusion list), and throws it away and draws again if any rule is broken. Keeping only valid draws means every valid assignment is equally likely.

How do I keep couples from drawing each other?

Add a line such as “Alex > Bea” to the exclusions box. With “exclusions work both ways” ticked, which is the default, that stops Alex giving to Bea and Bea giving to Alex. Untick it for one-way rules, for example if someone already bought a gift for one particular person.

How does everyone find out who they are buying for without the organiser seeing?

After the draw, copy each person’s own link and send it to them privately. Their link opens a page that shows only their match, behind a button. The organiser can take part too, as long as they do not open anyone else’s link or press “show all pairs”.

Are the private links secure?

They keep a match hidden from a casual glance, not from someone determined to look. The match is encoded in the link, not encrypted, so a person who decodes their own link sees only their own match, but anyone who gets hold of someone else’s link can see that person’s match. Send each link only to its owner.

What happens if the exclusions make a draw impossible?

The generator checks every possibility and tells you there is no valid assignment, instead of quietly ignoring a rule. That can happen with three people and one couple, for example. Remove an exclusion or add a person.

What is the “single loop” option?

Normally the draw can split into several small circles, such as Alex and Carlos giving to each other while the other four form a ring. A single loop forces one chain through everyone, A to B to C and back to A, which suits exchanges where gifts are handed over in turn around the room.

Other tools