Menu
Advertisement

Random Group Generator and Group Maker for Your Class

Paste your class list, choose how many groups or how many students per group, and add the students to keep apart or together. Every group is within one student of the others in size.

By Nethanel Bar, Co-founder & CEO

Last updated

Advertisement

Ready to actually learn to code?

Coddy teaches you by writing real code in your browser - interactive lessons, instant feedback, and AI help when you get stuck.

How to split a class into random groups

Teachers make groups for a lab, a project, a discussion or a review game, and a random draw is the fairest way to mix a class. Paste your roster, one name per line, choose Number of groups or Group size, and press Make groups. Everyone is shuffled into groups, and Shuffle again makes a new set from the same list. Before you draw, the line beside the button shows the sizes you will get, for example 4 groups: 7, 6, 6, 6.

When the class does not divide evenly, the leftovers are spread so that no group is more than one student bigger than another. With Number of groups the bigger groups come first. With Group size you choose what happens to the rest: Some groups smaller makes as many groups as it takes so that none is over the size (26 students in groups of 3 make eight groups of 3 and one of 2), and Some groups bigger lets the leftovers join groups (eight groups, two of 4 and six of 3). You never get 3, 3, 3 and a lonely 1 from a class of 10, and Group size never leaves anyone on their own: 25 students in pairs make eleven pairs and one group of 3.

Rules handle the pairs every teacher knows about. Keep apart puts two students in different groups and Keep together puts them in the same one, on every shuffle. If a rule cannot be kept, a box above the groups names it and says why. Copy gives the groups as plain text to paste into a slide or an email, and Print prints only the groups. Names stay in your browser: nothing is sent or saved, and a reload empties the page. Open the seating chart maker from the link under the tool and the same list is already there.

What you will learn from splitting a class

  • Splitting a class into groups is a division with a remainder. 25 divided by 4 is 6 with 1 left over, so one group gets a seventh student and the other three have 6.
  • Group size works the other way round: divide the class by the size, round up for Some groups smaller or down for Some groups bigger, then spread the class over that many groups. When rounding up would leave a student alone, as with pairs and an odd class, the generator rounds down instead.
  • Keep together rules chain. Keep Ana with Ben and Ben with Cara, and all three share a group, which is how a chain of rules can grow bigger than a group.
  • The sizes take a few lines of Python with divmod, as in the example below. Drawing the names is a shuffle, the same Fisher-Yates method that Python's random.shuffle uses.

How to use the random group generator

  1. Paste your class list

    Type or paste one name per line, for example a column copied from a spreadsheet. A list typed on one line, such as Ava, Ben, Chloe, is split at its commas, but a list of several lines never is, so Doe, Jane stays one name. Every line is a student: two students called Emma stay two, and the second shows as Emma (2). Roster numbers work as names too.

  2. Choose how to split

    Pick Number of groups (it starts at 4) or Group size. With Group size, choose Some groups smaller or Some groups bigger for the students left over. The line beside the button shows the sizes before you draw.

  3. Add rules if you need them

    Press Add a rule, choose Keep apart or Keep together and pick the two students from the names in the box. Add the rules once the list is in, up to 30 of them.

  4. Make the groups

    Press Make groups. Each card shows the group number, how many students it has and their names. Press Shuffle again for a new draw with the same settings and rules.

  5. Copy or print

    Copy puts the groups on your clipboard as text, each group's title followed by one name per line. Print opens your browser's print dialog with only the groups on the page.

Group sizes for common class sizes

What the generator makes for each class size, worked out with its own rule. "7 of 3, 2 of 2" means seven groups of 3 and two groups of 2.

Students4 groupsGroups of 3, some smallerGroups of 3, some biggerGroups of 4, some smallerGroups of 4, some bigger
204 of 56 of 3, 1 of 22 of 4, 4 of 35 of 45 of 4
222 of 6, 2 of 56 of 3, 2 of 21 of 4, 6 of 34 of 4, 2 of 32 of 5, 3 of 4
244 of 68 of 38 of 36 of 46 of 4
251 of 7, 3 of 67 of 3, 2 of 21 of 4, 7 of 34 of 4, 3 of 31 of 5, 5 of 4
273 of 7, 1 of 69 of 39 of 36 of 4, 1 of 33 of 5, 3 of 4
284 of 78 of 3, 2 of 21 of 4, 8 of 37 of 47 of 4
302 of 8, 2 of 710 of 310 of 36 of 4, 2 of 32 of 5, 5 of 4
324 of 810 of 3, 1 of 22 of 4, 8 of 38 of 48 of 4

Random group generator examples

A class of 25 in four groups

Paste a small example into the tool and change one part at a time.

The line beside the button reads 4 groups: 7, 6, 6, 6. 25 divided by 4 is 6 with 1 left over, so Group 1 gets 7 students and Groups 2 to 4 get 6. Every Shuffle again mixes the class into new groups of the same sizes.

Groups of 3 from a class of 26

Copy the original value, run the tool, then compare the result.

With Some groups smaller you get 9 groups: eight of 3 and one of 2. Switch to Some groups bigger and you get 8 groups: two of 4 and six of 3. Either way no group is more than one student away from the others.

Partners for an odd number of students

Take a value from your own work and use this tool to inspect or prepare it.

The line beside the button reads 12 groups: 3, 2, 2, and so on, and you get one group of 3 and eleven pairs, with a note above the groups: Nobody is left on their own: one group has 3. Some groups bigger gives the same twelve groups without the note.

The group sizes in Python

Group sizes
def even_sizes(students, groups):    groups = min(groups, students)    base, extra = divmod(students, groups)    return [base + 1] * extra + [base] * (groups - extra)
def sizes_by_group_size(students, size, leftover="smaller"):    if size >= students:        return [students]    if leftover == "bigger":        groups = students // size    else:        groups = -(-students // size)  # rounded up    sizes = even_sizes(students, groups)    if size >= 2 and 1 in sizes:  # nobody is left on their own        sizes = even_sizes(students, students // size)    return sizes
print(even_sizes(25, 4))print(sizes_by_group_size(26, 3, "smaller"))print(sizes_by_group_size(26, 3, "bigger"))print(sizes_by_group_size(25, 2, "smaller"))
Output

[7, 6, 6, 6] [3, 3, 3, 3, 3, 3, 3, 3, 2] [4, 4, 3, 3, 3, 3, 3, 3] [3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]

The three examples above in two functions. divmod gives the size every group gets and how many groups get one more, which is why the sizes never differ by more than one; the last check turns twelve pairs and a single into eleven pairs and a group of 3.

Common mistakes when making random groups

  • Asking for more groups than there are pairs. 25 students in 20 groups leave 15 groups with a single person, and a note above the groups says so; ask for fewer groups or use Group size.
  • Pasting the roster twice. Every line is a student, so a name that appears twice is kept twice and numbered, and the line under the box says which names were numbered. Delete the extra lines if they are copies, not two students.
  • Tying too many students together. Keep together rules chain, so a chain of four students cannot be kept in groups of 3, and the box above the groups lists the rules that broke.
  • Changing the list after adding rules. A rule names two students on the list; take one of them off and the rule is listed as not kept because a name is no longer on the list.
  • Expecting the groups to be there tomorrow. Nothing is saved, so copy or print the groups before you close or reload the page.

Random group generator FAQ

How do I make random groups from a class list?

Paste the names, one per line, choose Number of groups or Group size, and press Make groups. The generator shuffles the list and deals it into groups whose sizes differ by at most one. Shuffle again gives a new draw.

What happens when the class does not divide evenly?

The leftovers are spread over the groups, so sizes differ by at most one. With 25 students in 4 groups, one group has 7 and three have 6. In Group size mode you choose whether the extra students make some groups smaller or some groups bigger.

What is the difference between Some groups smaller and Some groups bigger?

Some groups smaller keeps every group at the size or below, so it makes more groups: 10 students in groups of 3 become 3, 3, 2 and 2. Some groups bigger keeps the number of full groups and adds the leftovers to them: 4, 3 and 3. Neither leaves anyone on their own: in pairs, an odd student always joins a pair.

Can I keep certain students apart or together?

Yes. Add a rule, choose Keep apart or Keep together and pick the two students. Rules hold on every shuffle when the sizes allow it. Keep together rules chain, so Ana with Ben and Ben with Cara put all three in one group. Two students with the same name can each be picked: the second is listed as Emma (2).

What happens when a rule cannot be kept?

The groups are still made, and a box above them lists each rule that broke with the reason: a name is no longer on the list, the same students are also kept together, more students are kept together than one group holds, or no arrangement keeps every rule. When a pair is kept both apart and together, the together rule wins.

Can the generator balance groups by gender or ability?

No. The draw is random and it has no levels, genders or captains. To spread out particular students, add Keep apart rules for them.

How many names and groups can I use?

Up to 300 names, 100 groups and 30 rules. You need at least 2 names to make groups. No group is ever empty: if you ask for more groups than there are pairs of students, some groups have a single person and a note above the groups says how many.

Is my class list saved or sent anywhere?

No. The groups are drawn in your browser and nothing is sent or stored. The list stays while you move to the seating chart maker and back, and a reload empties it.

Other developer tools

Coddy programming languages illustration

Learn to code with Coddy

Get started