Despite numerous studies on the relationship between urban form and building energy demand, understanding the impact mechanisms of urban form is still insufficient. Here, we identified the direct and indirect influences of urban form on building energy demand. The direct influence includes the blocking of solar radiation. The indirect influence is exerted through the urban heat island (UHI) effect as different urban forms produce different UHI intensities. The UHI effect was calculated using the urban weather generator (UWG) tool. Then, the analysis of the direct and indirect influences on the building energy demand was carried out using building energy modeling (BEM) based on the output of UWG. Five cities in different building climate zones in China were investigated, and the corresponding direct and indirect influences were quantified based on the proposed UWG + BEM framework. Results show that warmer temperatures lead to an average increase in space cooling of 16 %–46 % while reduced space heating of 8 %–17 %. The shading of surrounding buildings allows an increase of 7 %–36 % in space heating and a decrease of 14 %–48 % in space cooling compared to that of an isolated building. In addition, direct influence due to shading is prominent in Shuangyashan, Xuzhou, and Fuzhou, accounting for 50 %, 80 %, and 57 % of variations in building energy consumption.