The forest spatial structure and diversity of tree species, as the important evaluation indicators of forest quality, are key factors affecting forest carbon storage. To analyze the impacts of biodiversity indices and stand spatial structure on forest carbon density, five tree diversity indices were calculated from three aspects of richness, diversity and evenness, and three indices (Reineke’s stand density index, Hegyi’s competition index and Simple mingling degree) were calculated from stand spatial structure. The relationships between these eight indices and forest carbon density were explored using the Structural Equation Model (SEM). Then, these eight indices were used as characteristic variables to predict the aboveground carbon density of trees (abbreviated as forest carbon density) in the sample plots of the National Forest Resources Continuous Inventory (NFCI) in Shaoguan City in 2017. Multiple Linear Regression (MLR) and four typical machine learning models of Random Forest (RF), Tree-based Piecewise Linear Model (M5P), Artificial Neural Network (ANN) and Support Vector Regression (SVR) were used to predict the forest carbon density. The results show that: (1) Based on the analysis results of the structural equation model (SED), the species diversity and forest stand spatial structure have greater impacts on carbon density. (2) The R2 of all the five prediction models is greater than 0.6, among which the random forest model is the highest. (3) Based on the calculation results of optimal model of RF, the mean forest carbon density of Shaoguan city in 2017 was 43.176 tC/ha. The forest carbon density can be accurately estimated based on the species diversity index and stand spatial structure with machine learning algorithms. Therefore, a new method for the prediction of forest carbon density and carbon storage using species diversity indices and stand spatial structure can be explored. By analyzing the impacts of different biodiversity indices and stand spatial structure on forest carbon density, a scientific reference for the making of management measures for increasing forest carbon sinks and reducing emissions can be provided.