Cooperation in animals and humans is widely observed even if evolutionary biology theories predict the evolution of selfish individuals. Previous game theory models have shown that cooperation can evolve when the game takes place in a structured population such as a social network because it limits interactions between individuals. Modularity, the natural division of a network into groups, is a key characteristic of all social networks but the influence of this crucial social feature on the evolution of cooperation has never been investigated. Here, we provide novel pieces of evidence that network modularity promotes the evolution of cooperation in 2-person prisoner's dilemma games. By simulating games on social networks of different structures, we show that modularity shapes interactions between individuals favouring the evolution of cooperation. Modularity provides a simple mechanism for the evolution of cooperation without having to invoke complicated mechanisms such as reputation or punishment, or requiring genetic similarity among individuals. Thus, cooperation can evolve over wider social contexts than previously reported.