This study examines whether China's New Environmental Protection Law (NEPL), implemented in 2015, can improve the ESG performance of heavy polluters. Using A-share listed companies from 2010 to 2020 as our sample, we find that the NEPL significantly enhances ESG performance, especially for non-state-owned and labor-intensive enterprises. Furthermore, the moderating effect of digital transformation within enterprises has facilitated the NEPL's impact on enhancing ESG performance. These findings have important implications for environmental regulation in promoting ESG performance, realizing green transformation, and achieving high-quality and sustainable economic development.