Abstract.This paper studies the formation of peer groups entailing the joint production of public goods. In our model agents choose their peers and have to pay a connection cost for each member added to the group. After groups are formed, each agent selects a public project to make a costly contribution to, and all members of the group experience the bene…ts of these contributions. Since agents di¤er in how much they value one project relative to the other, the group's preferences a¤ect the generated pro…le of public goods. We characterize mutually optimal groups, groups that are optimal for all their members. When contribution costs are low relative to connection costs, mutually optimal groups must be su¢ ciently homogeneous. As contribution costs increase relative to connection costs, agents desire more connections, which in turn raises the risk of free riding. Extreme peers are then more appealing, since they are more willing to contribute, and polarization arises.