Private firms in China are contributing immensely to the country's economic growth. However, increasing the capital cost of private firms in China is a big challenge that needs to be addressed. This study intends to examine the role of optimal corporate social responsibility (CSR) investment while lowering the cost of equity capital and debt capital in Chinese private firms. In addition, this research study reveals the moderating role of state‐owned shares in the association between CSR and private firms' capital costs. By taking a sample of Chinese private firms from 2011 to 2021, this study employs the CSR optimization method. The findings show that CSR optimization tends to reduce the cost of equity capital and debt capital in Chinese private firms. Further investigation shows that over‐investment in CSR increases the cost of capital. Moreover, an increase in state‐owned shares strengthens the negative relationship between the cost of debt capital and optimal CSR investments. The present study's findings are helpful for Chinese firms to undertake optimal CSR investment.