PurposeWhile prior studies predominantly focus on the overall impact of digital transformation on environmental, social and governance (ESG) performance, this study employs dynamic capability theory to examine two different dimensions of digital transformation, namely digital transformation quantity and digital transformation structure, and how they influence the ESG performance of enterprises. The mediating roles of social attention and green innovation are investigated to further explore the underlying mechanisms.Design/methodology/approachThe authors apply fixed effects models and empirically test the hypotheses using samples of Chinese A-share listed companies from 2011 to 2020. In addition, difference-in-differences and instrumental variable methods are used in the robustness test.FindingsWhen digital transformation is categorized into quantity and structure, the impact mechanisms are found to be distinct. Externally, digital transformation quantity attracts social attention, aiding enterprises in evolutionary adaptability and acquiring resources to support ESG practices. Internally, digital transformation structure fosters green innovation, enabling enterprises to overcome technical obstacles and harness technology’s potential to enhance their ESG performance.Originality/valueThis study contributes to the current knowledge by differentiating digital transformation into quantity and structure, which helps to further explore the mechanism of digital transformation on ESG and address the research gap. Meanwhile, the concept of adaptability in the dynamic capability theory is employed to construct the model, offering a deeper perspective and expanding the theory. This nuanced investigation of the mediating effects of social attention and green innovation elucidates how different dimensions of digital transformation contribute to the development and utilization of dynamic capabilities, thereby enhancing enterprises’ ESG performance.