Draw Secret Santa pairs with exclusions

Assign every participant one different gift recipient while enforcing optional two-way exclusions.

freeworks offlinenothing uploaded
ToolSecret Santa Drawer
Input
Output
Put this on your own site

The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.

Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.

Preview

How it works

Each attempt shuffles the participant list into receiver positions and accepts the permutation only when nobody maps to themselves or an excluded partner. Invalid permutations are retried at most 500 times, which prevents impossible constraints from trapping the browser in an endless search.

  • Three unique names are the minimum because duplicate labels cannot identify people and a two-person exchange has only one forced pairing.
  • An absent seed draws from Web Crypto; a supplied seed replays the same search sequence.

Worked example

Four people, one couple excluded
Each exclusion line is a pair who should not draw each other
Input
											Names: ["Ana","Ben","Cleo","Dan"]
Exclusions: ["Ana, Ben"]
Seed: office-2026
										
Output
												Ana -> Cleo
Ben -> Dan
Cleo -> Ana
Dan -> Ben
											

When to use this

Office exchanges map colleagues one to one, family draws exclude partners, and club organisers can rehearse constraints with a seed before making an unseeded private assignment.

Edge cases

  • Two people with the same display name are rejected because giver and recipient lines would be ambiguous.
  • Entering Ana, Ben forbids both Ana → Ben and Ben → Ana, so couples do not need two mirrored exclusions.
  • When all three pairs in a three-person group are forbidden, no derangement exists and the search reports failure after 500 attempts.

References