Keep a roster for each class, set how many groups of each size you want, and deal them out. Names you mark as "keep apart" won't land together.
One per line, or separated by commas.
Mix as many sizes as you need — 5 groups of 3 and 3 groups of 4 is fine.