CodeKitHub
Generator Tools

Draw Names Generator

Last updated:

Drawing names for a Secret Santa or gift exchange by hand runs into a real math problem: a pure random shuffle can accidentally assign someone to themselves, and re-drawing until it "looks right" isn't actually random anymore. This tool solves that properly — enter everyone's name, and it computes a derangement (a shuffle with the mathematical guarantee that no one lands on their own name), then hides each result behind a tap-to-reveal button so people can check their own assignment on a shared screen without seeing anyone else's.

What Is This Tool?

A derangement is a specific mathematical concept: a permutation (reordering) of a set where no element ends up in its original position. Applied to a gift exchange, that means shuffling everyone's name into a new order such that nobody is paired with themselves — exactly the constraint a fair Secret Santa draw needs, and exactly what a naive `array.sort(() => Math.random() - 0.5)` shuffle does NOT guarantee on its own.

This tool generates a derangement by repeatedly shuffling the list with a randomized algorithm and checking the self-assignment constraint, using `crypto.getRandomValues()` for the underlying randomness rather than `Math.random()` — the same cryptographically secure source used by this site's [Password Generator](/password-generator/) and [Random Letter Generator](/random-letter-generator/).

The reveal-button design solves a separate, very practical problem with drawing names as a group: showing every assignment on screen at once spoils the surprise for everyone at the same time. Hiding each person's result behind its own button lets one device be passed around (or a screen be shared) so each person checks only their own name.

Why Use It?

  • It's the office holiday party and someone just remembered nobody set up Secret Santa — type the 14 names from the team chat into the box and draw pairs in the meeting before people scatter for lunch.
  • Your family group chat can't agree on who's buying for whom this year, and half the group would rather not download another app just for a gift draw — pull this up on one phone, pass it around the table, and let each person tap their own reveal button.
  • Someone quit the group two days before the exchange and now the spreadsheet from last year is wrong — re-paste the updated name list and draw again in seconds instead of manually fixing pairings by hand.
  • You tried a quick `sort(() => Math.random() - 0.5)` shuffle for a work exchange and someone got assigned to themselves — this tool exists specifically to rule that out with a guaranteed derangement instead of a lucky reshuffle.
  • You want the reveal to happen live on a video call without anyone else's assignment flashing on screen — share your screen, and each person tells you when to click their row so only they see it.

How to Use

  1. Type each participant's name on its own line — at least 3 different names.
  2. Click "Draw pairs" — the tool computes a valid derangement so nobody is paired with themselves.
  3. Each participant's row shows their name with a hidden result — pass the device around or share the screen, and have each person click their own "Tap to reveal" button to see who they're giving a gift to.
  4. Click reveal again to hide it once someone has checked their result, keeping the screen ready for the next person.

Example

Input

Alice, Bob, Carol, Dave

Output

Alice → Carol, Bob → Dave, Carol → Bob, Dave → Alice

Every run produces a different valid derangement — this is one example outcome. Notice no one is assigned to themselves, which is the one hard constraint a real Secret Santa draw needs and a plain random shuffle doesn't guarantee.

Derangement vs. a plain random shuffle

A plain shuffle and a derangement look similar but only one of them is actually safe for a gift exchange.

MethodCan assign someone to themselves?Fair to re-roll until it "looks right"?
Plain random shuffleYes — a real possibility, especially in small groupsNo — manually rejecting bad results biases the outcome
Derangement (this tool)No — mathematically excluded by constructionN/A — every valid result already satisfies the constraint

Related tools

For other random draws and generators, try these tools.

Fantasy Name Generator · Random Number Generator · Random Letter Generator

Running a group draw without spoiling it for yourself

The trickiest part of a Secret Santa draw isn't the randomness — it's making sure the person running the draw doesn't accidentally see everyone's assignment while setting it up. A few habits make that easier.

  • Type the name list and click "Draw pairs" without scrolling through the results yourself — hand the device straight to the first participant instead of previewing who got whom.
  • If you're the organizer and also a participant, ask someone else to hold the device for your own reveal, or wait until last so nobody feels rushed watching you check.
  • For a remote group, screen-share the page but keep your cursor off the reveal buttons — narrate whose turn it is and let each person click their own row over voice or chat.
  • If the group is large, go in the same order as a seating chart or meeting attendee list so nobody is skipped or double-checked by accident.

Frequently Asked Questions

What happens if a name is entered twice?

The tool requires every name to be unique before it will draw — if it detects a duplicate line, it asks you to fix the list first, since two participants with the identical name would make it impossible to tell their results apart.

Can someone draw their own name?

No — the tool specifically computes a derangement, a shuffle with the mathematical property that no element (person) ends up mapped to its own original position. That guarantee is enforced by the algorithm, not left to chance the way a plain random shuffle would.

What's the minimum number of people needed?

Three. With only two people, a derangement is impossible without them simply being assigned to each other every time, which isn't meaningfully random, so the tool requires at least three participants.

How do we keep results private if we're all looking at the same screen?

Each participant's result is hidden behind its own "Tap to reveal" button rather than being shown all at once. Pass the device (or share the screen) to each person in turn, have them reveal and note only their own row, then click it again to hide it before passing it to the next person.

Are the names or the draw result sent to a server?

No. Everything — reading the names, computing the derangement, and displaying the reveal buttons — happens entirely in your browser. Nothing is uploaded, and closing the tab clears everything, so there's no draw history left anywhere to accidentally spoil it.

Can I exclude specific pairs, like couples who shouldn't buy for each other?

Not currently — the derangement only guarantees no one is assigned to themselves, it does not exclude other specific pairings like spouses or siblings. If that matters for your group, check the result and manually re-draw if a pairing you wanted to avoid comes up.

What happens if I refresh or close the tab partway through revealing results?

The draw is lost — nothing is saved between page loads, by design, so there's no leftover record that could spoil the surprise later. If that happens, just re-enter the names and draw again; you'll get a new (different) valid derangement.

Can two people run separate draws and get different results for the same names?

Yes — every draw is freshly randomized using `crypto.getRandomValues()`, so entering the same list of names twice will very likely produce two different valid derangements, not the same pairing repeated.

Is there a maximum number of participants?

No hard limit is enforced — the derangement algorithm works the same way whether you enter 3 names or 30. Very large groups may just take a moment longer to compute, though in practice this is imperceptible for anything under a few hundred names.

Does the order I type names in affect who gets assigned to whom?

No — the shuffle is randomized independently of input order, so typing names alphabetically, by seating chart, or in random order has no effect on the fairness or outcome of the draw.

Related Tools