Based on the panel data of 284 prefecture-level city in China from 2005 to 2019, this paper measures the urban capital allocation efficiency and takes smart city construction as a quasi-natural experiment. The multi-period difference-in-differences (DID) model has been built to verify the internal mechanism and practical effect of smart city construction driving the optimal allocation of capital. The results show that the construction of smart cities has significantly improved the efficiency of capital allocation, and the conclusion remains valid after a series of robustness tests; Mechanism analysis shows that strengthening environmental regulations and improving innovation capabilities, together with the construction of smart cities, have promoted the improvement of capital allocation efficiency; The heterogeneity analysis indicates that the effect of smart city construction on capital allocation efficiency is influenced by the administrative level and regional heterogeneity characteristics of the city. This paper provides empirical evidence for the policy effectiveness of smart city construction and provides policy enlightenment on how to optimize capital allocation.