Abstract Taking 285 prefecture-level and higher cities in China from 2006 to 2022 as research subjects, this study leverages the quasi-natural experiment of the launch of public data openness platforms at the prefecture level. Using a difference-in-differences model, it empirically analyzes the impact effect and underlying mechanisms of public data openness on local governments’ ability to “stabilize foreign investment.” The results show that the openness of public data has effectively increased the scale of foreign investment inflows and enhanced the ability of each city to attract foreign capital. This conclusion remains valid even after controlling for endogeneity and undergoing multiple robustness tests. The Heterogeneity analysis indicates that the aforementioned effect is more pronounced in regions with strong manufacturing sectors and favorable business environments. Mechanism analysis reveals that public data openness optimizes the regional business environment by reducing government intervention, facilitating fair competition and enhancing governance capacity, thereby enhancing the region’ s attractiveness to foreign investment. Further analysis demonstrates that public data openness exerts a stronger attraction for investments originating from countries with more developed digital economies. Furthermore, it significantly reduces the relative scale of foreign divestment and enhances market concentration among foreign-invested enterprises. The findings offer new policy insights and decision-making references for local governments in their efforts to “stabilize foreign investment” .