The development of information technology has created conducive conditions for the digital economy. The digital economy is regarded as a critical pathway for transforming traditional economic models. Green total factor productivity serves as an indicator for assessing the quality of economic development. During pivotal periods of economic transition, the digital economy and green total factor productivity have emerged as two prominent themes for achieving sustainable economic development. But the impact of digital economy on green total factor productivity is less discussed. Innovation environment refers to a confluence of conditions shaped by factors such as talent, funding, cultural atmosphere and government policies, all of which collectively support innovative activities within a region. The institutional environment encompasses the aggregate of economic, political, social, and legal rules. Currently, there is little discussion on bringing innovation environment and institutional environment into the impact of digital economy on green total factor productivity. To fill the research gap, this paper adopts the Slack based measure-Directional distance function model and Malmquist-Luenberger productivity index to measure green total factor productivity in each region based on the panel data collected from 30 provinces in China from 2004 to 2019. Generalized Method of Moments method is constructed to carry out an empirical study on the impact of digital economy on green total factor productivity. This paper constructs a panel threshold model with innovation environment and institutional environment as threshold variables. In further analysis, this paper employs panel quantile regression for the empirical analysis of the impact of the digital economy on green total factor productivity. Further analysis elucidates the evident disparities in the influence of the digital economy on green total factor productivity at various levels. The research results can provide a guide for discussing the green value of the digital economy and its role in fostering the development of a green economy.