How do you split a class into random groups fairly?
Put the whole list in a random order with a proper shuffle, then deal the names out in turn: the first five to group 1, the next five to group 2, and so on. Done right, every student is equally likely to land with every classmate. For 30 students in 6 groups of 5, any two friends share a group 13.8% of the time, exactly 4 in 29.
This generator does that in your browser with the Fisher-Yates shuffle and the browser's cryptographic random numbers, so no one can predict or steer the result. The names you paste are not uploaded, stored or added to the link. Why the quick shortcuts many people use are slightly unfair is explained in How random is random? Fair ways to pick teams.
Key results
- Group sizes: split by number of groups and sizes differ by at most one. 30 students in 4 groups gives 8, 8, 7, 7.
- Leftovers: asking for groups of 4 from 30 gives either 2 groups of 5 and 5 groups of 4 (some groups one bigger) or 6 groups of 4 and 2 groups of 3 (some groups one smaller).
- Chance two friends end up together: (size − 1) ÷ (class − 1) for equal groups. 13.8% for groups of 5 in a class of 30, 3.4% for pairs.
- Number of possible splits: 30 students into 6 groups of 5 can be split 1.23 × 10¹⁷ different ways, and each one is equally likely.
Six ways to use it
Each button loads a made-up sample class into the generator.
30 students into 6 groups of 5
by number of groupsSet the number of groups to 6 and every table gets five students. Any one student has 29 classmates and 4 seats beside them, so the chance a given friend joins them is 4 ÷ 29 = 13.8%. There are 1.23 × 10¹⁷ different ways to make these groups.
Random partners: 15 pairs
by group sizeChoose 2 people per group for partner work. Each student is paired with one of 29 classmates, so any particular partner comes up 3.4% of the time. With an odd number of students one group becomes a three.
Groups of 4 from 30: 2 groups of 5 and 5 groups of 4
leftovers30 does not divide by 4. The tool can make 7 groups and give two of them a fifth student, or make 8 groups with two of them a student short (6 groups of 4 and 2 groups of 3). Switch with the option under the group size.
Keep three pairs apart in 5 groups of 6
keep-apart pairsList pairs who should not work together, one per line. The tool reshuffles until none of them share a group. Each pair lands together 17.2% of the time, so roughly 57% of shuffles keep all three apart and it usually needs only one or two tries. Because it simply throws away the bad shuffles, every allowed arrangement stays equally likely.
Two teams of 12 for a game
teamsFor a PE game or a quiz, choose 2 groups. With 24 players, a given friend is on your team 47.8% of the time, 11 in 23. Picking by captains is quicker to explain but leaves the same students waiting to be chosen last; a shuffle does not.
25 students in threes: 7 groups of 3 and 2 groups of 2
by group size25 is not a multiple of 3. With some groups one smaller you get 7 groups of 3 and 2 groups of 2; with some one bigger you get 1 group of 4 and 7 groups of 3. Pick whichever suits the task: twos for quick talk, fours where a role needs filling.
Splitting a class of 30
| Setting | Groups | Two friends together | Possible splits |
|---|---|---|---|
| Pairs | 15 groups of 2 | 3.4% | 6.19 × 10¹⁵ |
| Groups of 3 | 10 groups of 3 | 6.9% | 1.21 × 10¹⁸ |
| Groups of 4, some bigger | 2 groups of 5 and 5 groups of 4 | 11.5% | 9.64 × 10¹⁸ |
| Groups of 4, some smaller | 6 groups of 4 and 2 groups of 3 | 9.7% | 2.68 × 10¹⁹ |
| 6 groups | 6 groups of 5 | 13.8% | 1.23 × 10¹⁷ |
| 5 groups | 5 groups of 6 | 17.2% | 1.14 × 10¹⁶ |
| 3 groups | 3 groups of 10 | 31.0% | 9.25 × 10¹¹ |
| 2 teams | 2 groups of 15 | 48.3% | 7.76 × 10⁷ |
Exact values, worked out by counting. "Two friends together" is the chance that two named students land in the same group. "Possible splits" counts groups by who is in them, not by group number.
How the generator works
Names are read one per line, or separated by commas or semicolons. Numbering and bullet points at the start of a line are removed, and blank lines are skipped.
The list is shuffled with the Fisher-Yates method: going from the last name to the first, each name swaps places with a randomly chosen name at or before it. Random numbers come from the browser's crypto.getRandomValues, and values that would favour some names are thrown away and redrawn.
The shuffled list is dealt into groups in order. By number of groups, sizes differ by at most one. By group size, you choose whether leftovers make some groups one bigger or one smaller.
Keep-apart pairs are handled by shuffling again until no pair shares a group, up to 5,000 tries. If that cannot be done, for example with only one group, it shows the closest arrangement and says so.
What the model leaves out
- Balancing by ability or behaviour: the tool is purely random. For mixed-ability groups, sort by hand first, or use keep-apart pairs.
- Memory between lessons: nothing is saved, so it cannot avoid repeating last week's groups. Re-roll if a group looks too familiar.
- Named roles: it does not assign a leader or scribe. Ask the first name on each card to take the role, which is just as random.
Common misconceptions
"Sorting with a random comparison is a shuffle." It is not. With three names and insertion sort, the original order comes up 25% of the time instead of 16.7%.
"Swapping each name with any random position is fair." For three names that gives 27 equally likely runs but 6 orders, and 27 does not divide by 6, so some orders come up 18.5% of the time and others 14.8%.
"A random byte modulo 30 is good enough." 256 is not a multiple of 30, so 16 of the 30 names get picked 3.52% of the time and the rest 3.13%.
Frequently asked questions
How do I split a class into random groups?
Paste the names, one per line or separated by commas, choose the number of groups or the group size, and the groups appear at once. Press Re-roll for a different draw.
Is this random group generator really fair?
Yes. It uses a Fisher-Yates shuffle driven by your browser's cryptographic random numbers, so every way of splitting the class is equally likely. In 6 groups of 5 from 30, any two students share a group exactly 13.8% of the time.
Are the names I paste stored or sent anywhere?
No. Everything happens in your browser. The names are not uploaded, saved or written into the page link, and they are gone when you close the tab.
What happens if the class does not divide evenly?
By number of groups, sizes differ by at most one. By group size, you choose: 30 in groups of 4 becomes 2 groups of 5 and 5 groups of 4, or 6 groups of 4 and 2 groups of 3.
Can I keep certain students apart?
Yes. Open Keep apart and list pairs one per line, such as Sam + Alex. The tool reshuffles until no pair shares a group.
Keep learning
A 100-year flood can happen twice. Here is what the odds actually mean
A reproducible Python analysis reconstructs an official flood-probability table and separates annual chance, long-term risk, and repeated exceedances.
Ascending order program in python without sort function
Sorting numbers in ascending order is one of the most basic operations in programming, often achieved using built-in functions like Python’s sort() or
The Discovery of the Ninth Dedekind Number After 32 Years
After 32 years of Searching Mathematicians Discover The Ninth Dedekind Number and it is very large 286 386 577 668 298 411 128 ...