With the new generation of technological revolution, the digital economy has progressively become a key driver of global economic development. In this context, how to promote green economic growth and improve green total factor productivity (GTFP) with the help of the digital economy is an important issue that urgently needs empirical research. We adopted the panel data of 278 Chinese prefecture-level cities from 2011 to 2020 to test whether the digital economy improves the GTFP through the Gaussian Mixed Model (GMM) dynamic panel model. The moderating effect model has been used to explore the impact mechanism from the perspectives of industrial structure upgrade and environmental regulation. In addition, a grouping regression was applied to the sample cities to test the heterogeneous impact of the digital economy on the GTFP. Based upon the empirical findings, this work has the following conclusions. First, the digital economy plays a significant role in improving the GTFP. Second, an industrial structure upgrade has a positive moderating effect on the ability of the digital economy to enhance the GTFP. The environmental regulation, in contrast, has a negative moderating effect. Third, the digital economy exerts heterogeneous impacts on the GTFP across regions, but not at the city level.