  Corruption is a social plague: gains accrue to small groups, while its costs
are borne by everyone. Significant variation in its level between and within
countries suggests a relationship between social structure and the prevalence
of corruption, yet, large scale empirical studies thereof have been missing due
to lack of data. In this paper we relate the structural characteristics of
social capital of towns with corruption in their local governments. Using
datasets from Hungary, we quantify corruption risk by suppressed competition
and lack of transparency in the town's awarded public contracts. We
characterize social capital using social network data from a popular online
platform. Controlling for social, economic, and political factors, we find that
settlements with fragmented social networks, indicating an excess of
\textit{bonding social capital} have higher corruption risk and towns with more
diverse external connectivity, suggesting a surplus of \textit{bridging social
capital} are less exposed to corruption. We interpret fragmentation as
fostering in-group favoritism and conformity, which increase corruption, while
diversity facilitates impartiality in public life and stifles corruption.
