Abstract Rural communities in China still rely widely on coal and biomass, creating health, climate and development burdens. Choosing low-cost alternatives is difficult because infrastructure, population and technology costs change over time. Here we develop a spatially explicit cost–benefit model for 248,000 rural settlements, 323.9 million residents and more than 14 million records on infrastructure, energy prices and population change.