Constructing closed pore structures is essential for improving the plateau capacity of high-capacity hard carbon (HC) anodes for sodium-ion batteries. However, the absence of a straightforward and efficient strategy for constructing closed pores has hindered the advancement of high-capacity HC anodes. Here, we have developed a spatial confinement strategy for constructing closed pore structures using pyrolytic carbon (PC) as substrate and pyrolysis gas as the carbon source for chemical vapor deposition. The deposition of pyrolysis gas effectively tightens the pore entrance, thereby preventing electrolyte infiltration and transforming the open pores in the PC into highly efficient sites for sodium storage. The obtained optimal anodes demonstrate a remarkable specific capacity of 324.6 mAh g-1. More importantly, we calculate the kinetic diameters of the carbon source molecules from their iso-electron density surfaces and correlate them with the mechanism of closed pore formation, which will effectively guide the fabrication of closed pores for sodium storage.