Random Name Picker: how it works and how to build one
Pick a winner, split teams or shuffle a list. This guide explains what happens behind the button and shows the code, so you can build your own.
What it does
Paste names, one per line, and pick one or more winners at random, shuffle the list, or split it into teams of equal size. Good for giveaways, classrooms and team games.
When to use it
- Giveaways
- Classroom questions
- Team games and sprints
How to use it
- Paste names, one per line.
- Pick winners, shuffle or make teams.
- Copy the result.
Try it free in your browser, nothing is uploaded: https://eskillsfy.com/tools/random-picker
How it works
Picking fairly means shuffling fairly. The Fisher–Yates shuffle walks the list from the end and swaps each item with a random earlier one, giving every order the same chance. Winners are the first items of the shuffled list; teams are dealt round-robin.
Build it yourself
Here is the core of the tool. It has no dependencies unless noted, so you can paste it into any TypeScript or JavaScript project.
picker.ts (ts)
export function shuffle<T>(items: T[]) {
const a = [...items];
for (let i = a.length - 1; i > 0; i--) {
const j = crypto.getRandomValues(new Uint32Array(1))[0] % (i + 1);
[a[i], a[j]] = [a[j], a[i]];
}
return a;
}
export const pickWinners = (names: string[], k: number) => shuffle(names).slice(0, k);
export const makeTeams = (names: string[], t: number) =>
Array.from({ length: t }, (_, i) => shuffle(names).filter((_, j) => j % t === i));
Make it production-ready
- Shuffle once and reuse it for teams (the snippet shuffles per team for brevity).
- Add a spinning wheel animation.
Questions
Can someone win twice?
No. Each pick removes the winner from the draw unless you turn that off.
Free, runs in your browser, nothing is uploaded.