Purpose Although prior studies have examined the relationship between firms' digital orientation (DO) and environmental, social and governance (ESG) performance, their findings are mixed. The potential nonlinear nature of this relationship, particularly in heavily polluting industries, has been largely overlooked. This study addresses this gap by investigating an inverted U-shaped DO–ESG relationship. It draws on dynamic capability theory to explain the performance-enhancing role of DO and integrates the resource-based view, attention-based view and organizational inertia theory to explain how excessive DO may ultimately erode ESG performance. Design/methodology/approach This study develops a multidimensional index of DO, encompassing strategic, governance, resource, and digital innovation realization. Using panel data from Chinese-listed heavily polluting firms from 2013 to 2022, we apply fixed-effects OLS models. Robustness is assessed through instrumental variable regression, natural spline estimation and generalized additive models (GAM), among other methods. Findings The results reveal an inverted U-shaped relationship between DO and ESG performance, suggesting that excessive DO may diminish ESG returns. Green innovation and information transparency act as mediators, while institutional investor site visits moderate the relationship between DO and ESG performance. Originality/value This study advances the literature by documenting and validating the nonlinear effects of DO on ESG outcomes. It develops and validates a comprehensive DO measurement framework and uncovers both mediating and moderating mechanisms in ESG-salient, heavily polluting sectors. The findings offer practical guidance for managers, policymakers, and institutional investors seeking to align digital development with long-term sustainability objectives.