As the world' s largest energy consumer and carbon emitter, China faces a serious situation in energy conservation and emission reduction. However, China' s digital economy is still developing rapidly. In order to explore how the development of the digital economy affects energy consumption and CO2 emissions, this paper took the panel data of 30 provinces in China from 2011 to 2019 as a sample, used the entropy method to analyze the digital economy level of each province, and built a double fixed effect model to empirically analyze the 'positive U-shaped' or 'inverted U-shaped' relationship between the digital economy and energy or between the digital economy and CO2 emissions. The results showed that: (1) There were inter-provincial and regional differences in the level of digital economy in China. Guangdong Province and China' s eastern region had the highest level of digital economy, while Qinghai Province and the western region had the lowest level of digital economy. (2) Both the digital economy and ECSC and the digital economy and CESC had significant ' positive U-shaped' relationships, while the digital economy and ECST, the digital economy and ECEF, and the digital economy and CEEF all had significant 'inverted U-shaped' relationships. The energy-saving effect of the development of the digital economy was greater than the carbon emission reduction effect. (3) There was heterogeneity in the nonlinear relationship between the digital economy and ECSC, ECST, and ECEF, the digital economy and CESC, and CEEF in the eastern, central, western, and northeastern regions. (4) Digital infrastructure, digital innovation environment, digital user scale, and digital industry scale had different nonlinear effects on ECSC, ECST, and ECEF, as well as on CESC and CEEF. Accordingly, to provide empirical support and a theoretical basis for China's development of the digital economy while taking into account the effects of energy conservation and carbon emission reduction, this study puts forward relevant policy suggestions from three aspects: narrowing the gap in the level of digital economy, formulating digital economy development policies, and focusing on key points for the development of the digital economy. These suggestions are also conducive to boosting China's goals of reaching peak carbon emissions and achieving carbon neutrality. [ABSTRACT FROM AUTHOR]