Aging and urbanization significantly impact the physical and mental well-being of the elderly population. Empirical investigations have highlighted the contribution of the built environment to promoting elderly health. However, there is a need for further exploration of the factors within the built environment that impact the subjective well-being (SWB) of the elderly. To address this, this study selected 50 communities in Guangzhou, where 1403 elderly people were surveyed. Employing the random forest, we have identified contributing factors of the built environment affecting the SWB of the elderly. Meanwhile, we used a prediction model constructed by random forest to predict the SWB level of the elderly. The results indicated that accessibility to parks (positive emotions (PA): 0.822, positive experiences (PE): 0.235), hospitals (PA: 0.680, PE: 0.546), and supermarkets (PA: 0.237, PE: 0.617) significantly contributed to PA and PE. On the other hand, factors such as population density had a significant contribution to negative emotions (NA: 0.431) and negative experiences (NE: 0.194). Based on the prediction results, the spatial distribution of SWB among the elderly can be derived. Overall, our study can provide planning and improvement strategies for built environments that promote SWB among the elderly.