High-quality development is the theme of China’s economic and social development in the new era, and corporate ESG performance is a comprehensive indicator for evaluating the level of corporate environmental responsibility, social responsibility and governance, as well as an important yardstick for identifying the high-quality development of enterprises. This paper takes Chinese non-financial listed companies from 2011 to 2022 as the research sample and empirically examines the impact of corporate nationalism culture on corporate ESG performance and its mechanism by quantifying corporate nationalism culture using the text of corporate annual reports, natural language processing and text analysis methods. The results of the study show that corporate nationalism culture significantly enhances corporate ESG performance. The mechanism analysis suggests that corporate nationalism culture, as an internal informal system, can play a governance role and promote corporate ESG practices by changing attention allocation and mitigating agency problems. The positive effect of corporate nationalism culture on corporate ESG performance is more pronounced in the grouping of firms with lower institutional investor shareholding, fewer analysts’ attention and embedded party organisations. A heterogeneity analysis reveals that the corporate nationalism culture driving effect on corporate ESG performance is more significant in the subsample of firms with weak financing constraints, in the growth period and in the decline period. This study reveals the positive role of soft cultural factors in enhancing corporate ESG performance, providing useful managerial evidence for companies to integrate ESG concepts at the strategic level for high-quality economic development.