# Secret Santa Generator

Type the names, one per line, add any people who should not draw each other (a couple, a household) and press Draw: everyone gets exactly one person to buy for, nobody gets themselves and no excluded pair is ever matched. The example draws 6 people with 2 exclusion groups: Ava buys for Elena, Ben buys for Dev, Chloe buys for Femi, Dev buys for Ava, Elena buys for Chloe, Femi buys for Ben. Keep it secret by passing the phone so each person taps to see their own match, or copy a private link for each person. Nothing is uploaded, no emails are sent and there is no sign-up.

Canonical page: https://ponderloop.com/tools/secret-santa-generator/
Updated: 2026-11-14

## How to use

How to draw Secret Santa names online

1. **Add the names**: One name per line, at least 3 and up to 100. A repeated name is counted once.
2. **Add exclusions (optional)**: Put people who should not draw each other on the same line, separated by a comma, an ampersand or a slash. Leave “Both directions” ticked for couples; untick it to stop only the first name on the line from drawing the others.
3. **Set a budget and a date (optional)**: They are shown with every match and included in the private links.
4. **Press Draw**: If the exclusions make a draw impossible, a message names the people who run out of options so you can relax one of the exclusions.
5. **Share the matches**: Pass the phone around, copy a private link for each person and send it yourself, or open the organizer list. Press Draw again for a new draw, and send new links.

## Reference tables and worked examples

### How many valid draws a group has

Draws where nobody picks themselves (derangements), compared with all possible orders. Exclusions remove some of these draws; a random shuffle is valid about one time in three.

| People | All orders (n!) | Nobody draws themselves | Share of all orders |
| --- | --- | --- | --- |
| 3 | 6 | 2 | 33.3% |
| 4 | 24 | 9 | 37.5% |
| 5 | 120 | 44 | 36.7% |
| 6 | 720 | 265 | 36.8% |
| 7 | 5,040 | 1,854 | 36.8% |
| 8 | 40,320 | 14,833 | 36.8% |
| 10 | 3,628,800 | 1,334,961 | 36.8% |
| 12 | 479,001,600 | 176,214,841 | 36.8% |

### How to write exclusions

One group per line. Everyone named on a line cannot draw anyone else on that line (both directions on). Names must match the names list; capitals and extra spaces do not matter.

| Line | Both directions on | Both directions off |
| --- | --- | --- |
| Ava, Ben | 2 blocked draws | 1 blocked draw |
| Ava & Ben & Chloe | 6 blocked draws | 2 blocked draws |
| Ava / Ben | 2 blocked draws | 1 blocked draw |
| Ava - Ben | 2 blocked draws | 1 blocked draw |
| Ava and Ben | 2 blocked draws | 1 blocked draw |

### What a private link contains

A link for one person ends in #s1.… and holds that person's name, their match, the budget and the date. The part after the # is read by this page in the browser and is never sent to a server.

| Part | Example | What it does |
| --- | --- | --- |
| prefix | s1. | Marks the format version. |
| salt and check | first 4 bytes | A 16-bit salt scrambles the rest; a 16-bit check catches a link that was cut off. |
| payload | 31 characters here | Giver, receiver, budget and date as scrambled text. Scrambled, not encrypted: see the FAQ. |

## How it works

Names are read one per line (or split at the commas of a single line), trimmed, with blank lines ignored and repeats counted once. Each exclusion line is split at commas, ampersands, slashes, plus signs, “ - ” or “ and ”, and each name is matched to the list ignoring case and extra spaces; a name that is not on the list is an error. A valid draw gives each giver one receiver with every receiver used once, no giver drawing themselves and no excluded pair. The tool first checks that one exists with Kuhn’s augmenting-path matching algorithm. If it does not, the failed search yields a Hall violator, a set of givers with fewer allowed recipients than members (Hall’s marriage theorem), and the message names them. Otherwise the list is shuffled with Fisher–Yates using unbiased random integers from crypto.getRandomValues, and the shuffle is accepted if it breaks no rule; accepted shuffles are uniform over all valid draws. After 300 rejected shuffles (very tight exclusions) the tool assigns givers one at a time, each choosing randomly among the recipients that still leave a valid draw possible; that always succeeds, but then the valid draws are not exactly equally likely. A private link is “s1.” plus the base64url of a 16-bit salt, a 16-bit check and the JSON of giver, receiver, budget and date, XOR-ed with a stream from the mulberry32 generator seeded by the salt. This hides the text from a glance and detects damage; it is not encryption. The static example uses a fixed seed so the page never changes between builds.

## FAQ

### Is the Secret Santa draw really random and fair?

Yes. The names are shuffled with a Fisher–Yates shuffle driven by your browser’s cryptographic random number generator (crypto.getRandomValues), and a shuffle is accepted only if nobody has themselves and no excluded pair is matched. Every valid draw is then equally likely. With 6 people there are 265 draws where nobody gets themselves, before any exclusions.

### How do exclusions work for couples and households?

Write each couple or household on one line, for example “Ava, Ben”. With “Both directions” ticked (the default) none of them can draw any other person on that line. If you untick it, only the first name on the line is blocked from drawing the others, which suits a one-way rule such as “last year’s match”. Exclusions are checked as hard rules, never as preferences.

### What does “impossible with these exclusions” mean?

Every person needs a different person to give to. If some people between them have fewer allowed recipients than there are people, no draw can exist, and the message names those people and who is left. Two people who exclude each other cannot be drawn alone, and in a group of three, one excluded pair is already impossible. Remove or loosen one exclusion and draw again.

### Are the names or results sent anywhere?

No. The draw runs in your browser, there is no server that receives names, and no emails are sent. Your list is not saved unless you tick “Remember this list on this device”, which keeps it in this browser only until you press Clear. If you allow analytics, the site learns that a button was pressed, never a name or a result.

### How secure are the private links?

They are private from servers, not from a curious participant. The match sits in the part of the link after the # sign, which browsers do not send to any server, so this site never sees it. But the text is only scrambled with a fixed method, not encrypted, so anyone who knows the format, or reads this page’s code, can decode a link in seconds. Send each link only to its owner, and use the pass-the-phone mode when you do not trust everyone to leave it alone.

### Does an odd number of people matter?

No. The draw is not made of pairs. Each person gives to one person and receives from one, so the group forms one loop or several, and any number from 3 up works. Two people drawing each other is possible when the group has loops of two; press Draw again if you want to avoid that. Groups of two are not offered, because both people would know their match.

### What if someone drops out after the draw?

If nobody has opened a link yet, remove the name and draw again. If people already know their matches, open the organizer list: the person who was drawing for the one who dropped out can take over the dropout’s recipient, as long as that is not themselves or an excluded person. Otherwise redraw for everyone and send new links.

### Can I redraw, and how do I stop people peeking?

Press Draw again for a completely new draw; links and cards from the earlier draw then no longer match, so send the new ones. The organizer list is hidden until you open it, and the pass-the-phone screen shows one match at a time behind a tap, then hides it again before the next person.

### How many names can it handle?

Between 3 and 100 names. Names are treated as Unicode text, so right-to-left names such as Hebrew or Arabic read in the right direction.

## Sources

- [Derangement: permutations with no fixed point (Wikipedia)](https://en.wikipedia.org/wiki/Derangement)
- [OEIS A000166: number of derangements](https://oeis.org/A000166)
- [Hall’s marriage theorem (Wikipedia)](https://en.wikipedia.org/wiki/Hall%27s_marriage_theorem)
- [Matching in graph theory (Wikipedia)](https://en.wikipedia.org/wiki/Matching_(graph_theory))
- [Fisher–Yates shuffle (Wikipedia)](https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle)
- [MDN: Crypto.getRandomValues()](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues)
- [RFC 3986 section 3.5: the fragment identifier](https://www.rfc-editor.org/rfc/rfc3986#section-3.5)

---

Cite as: Secret Santa Generator, ponderloop, https://ponderloop.com/tools/secret-santa-generator/, updated 2026-11-14
