Skip to content
Tool · Classroom

Random group generator

Paste your class list, choose how many groups or how many in each, and every student gets a table and a colour. Re-roll as often as you like, keep certain pairs apart, then copy, print or download the groups.

How many groups People in each group
If the class does not divide evenly
Keep apart (optional)

One pair per line, such as Sam + Alex. Those two will never share a group.

Groups…
Group sizes…
Two friends together…
Possible splits…
Kept apart…

    Names stay on this device. The list is shuffled in your browser and is never uploaded, saved or put in the page link. Close the tab and it is gone.

    Shuffle, then deal

    The class is put in a random order, then dealt into groups like cards: the first five names to group 1, the next five to group 2, and so on.

    30 names → 6 groups of 5

    Every order equally likely

    The shuffle swaps each name with a random one not yet placed, using your browser's secure random numbers. That gives each of the n! orders the same chance.

    n × (n − 1) × … × 1 = n!

    Keep-apart pairs

    If two students must not work together, the tool simply reshuffles until they are in different groups. Every allowed arrangement stays equally likely.

    P(same group) = s − 1n − 1

    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 groups

    Set 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.

    Groups 6 groups of 5 Friend with you 13.8% Possible splits 1.23 × 10¹⁷ Shuffle Fisher-Yates

    Random partners: 15 pairs

    by group size

    Choose 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 15 groups of 2 Any one partner 3.4% Possible pairings 6.19 × 10¹⁵ Odd class one trio

    Groups of 4 from 30: 2 groups of 5 and 5 groups of 4

    leftovers

    30 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.

    One bigger 2 groups of 5 and 5 groups of 4 One smaller 6 groups of 4 and 2 groups of 3 Friend with you 11.5% Possible splits 9.64 × 10¹⁸

    Keep three pairs apart in 5 groups of 6

    keep-apart pairs

    List 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.

    Groups 5 groups of 6 Pairs kept apart 3 One pair together 17.2% All apart, roughly 57%

    Two teams of 12 for a game

    teams

    For 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.

    Teams 2 groups of 12 Friend on your team 47.8% Possible splits 1,352,078 Picked last nobody

    25 students in threes: 7 groups of 3 and 2 groups of 2

    by group size

    25 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.

    One smaller 7 groups of 3 and 2 groups of 2 One bigger 1 group of 4 and 7 groups of 3 Friend with you 7.7% Possible splits 1.37 × 10¹⁵

    Splitting a class of 30

    SettingGroupsTwo friends togetherPossible splits
    Pairs15 groups of 23.4%6.19 × 10¹⁵
    Groups of 310 groups of 36.9%1.21 × 10¹⁸
    Groups of 4, some bigger2 groups of 5 and 5 groups of 411.5%9.64 × 10¹⁸
    Groups of 4, some smaller6 groups of 4 and 2 groups of 39.7%2.68 × 10¹⁹
    6 groups6 groups of 513.8%1.23 × 10¹⁷
    5 groups5 groups of 617.2%1.14 × 10¹⁶
    3 groups3 groups of 1031.0%9.25 × 10¹¹
    2 teams2 groups of 1548.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

    More simulations

    More everyday utilities tools

    See all science tools