While it is undeniable that the ability of humans to cooperate in large-scale societies is unique in animal life, it remains open how such a degree of prosociality is possible despite the risks of exploitation. Recent evidence suggests that social networks play a crucial role in the development of prosociality and large-scale cooperation by allowing cooperators to cluster; however, it is not well understood if and how this also applies to real-world social networks in the field. We study intrinsic social preferences alongside emerging friendship patterns in 57 freshly formed school classes ( n = 1,217), using incentivized measures. We demonstrate the existence of cooperative clusters in society, examine their emergence, and expand the evidence from controlled experiments to real-world social networks. Our results suggest that being embedded in cooperative environments substantially enhances the social preferences of individuals, thus contributing to the formation of cooperative clusters. Partner choice, in contrast, only marginally contributes to their emergence. We conclude that cooperative preferences are contagious; social and cultural learning plays an important role in the development and evolution of cooperation.