PurposeThe purpose of this study is to investigate whether the corporate environmental, social and governance (ESG) performance of enterprise is influenced by the enterprise digital transformation. In addition, this study explains how enterprise digital transformation affects ESG performance.Design/methodology/approachThe sample covers 4,646 nonfinancial companies listed on China’s A-share market from 2009 to 2021. The study adopts the fixed-effects multiple linear regression to perform the data analysis.FindingsThe study finds that enterprise digital transformation has a significant inverted U-shaped impact on ESG performance. Moderate digital transformation can improve enterprise ESG performance, whereas excessive digital transformation will bring new organizational conflicts and increase enterprise costs, which is detrimental to ESG performance. This inverted U-shaped effect is more pronounced in industrial cities, manufacturing industries and enterprises with less financing constraints and executives with financial backgrounds. Enterprise digital transformation mainly affects ESG performance by affecting the level of internal information communication and disclosure, the level of internal control and the principal-agent cost.Practical implicationsThe government should take multiple measures to encourage enterprises to choose appropriate digital transformation based on their own production behaviors and development strategies, encourage them to innovate and upgrade their organizational management and development models in conjunction with digital transformation and guide them to use digital technology to improve ESG performance.Social implicationsThis study shows that irrational digital transformation cannot effectively improve the ESG performance of enterprises and promote the sustainable development of the country. Enterprises should carry out reasonable digital transformation according to their own development needs and finally improve the green and sustainable development ability of enterprises and promote the sustainable development of society.Originality/valueThis study examines the relationship between enterprise digital transformation and ESG performance. Different from the linear relationship between the two in previous major studies, this study proves the inverse U-shaped relationship between enterprise digital transformation and ESG performance through mathematical theoretical model derivation and empirical test. This study also explores in detail how corporate digital transformation affects ESG performance, as well as discusses heterogeneity at the city, industry and firm levels. It is proposed that enterprises should take into account their own characteristics and carry out reasonable digital transformation according to their development needs.