The digital economy promotes economic development, industrial upgrading, and environmental protection. This article calculates the green total factor productivity (GTFP) based on the SBM-DDF model and uses the entropy method and principal component analysis to calculate the digital economy index. We use panel data from 282 Chinese cities to test the driving effect of the digital economy on green total factor productivity. The study results show that the digital economy significantly increases GTFP, and the heterogeneity of this impact is further explored. We also explored the mechanism of the digital economy in promoting green. The digital economy can indirectly increase industrial production efficiency by promoting innovation in green technologies.