Non-graphitic carbons have shown great potential in sodium ions batteries, however, major hurdle to address is the poor capacity performance. Herein, a facile strategy combining supramolecular chemistry polymerization and nanospace confinement carbonization is proposed to construct interconnected carbon foams with N,P co-doping (MNNPCs) to improve sodium storage performance. Electrochemical impedance spectroscopy (EIS) measurements demonstrate that defined MNNPCs display fast charge transfer at the electrode-electrolyte interface. And the Na+ diffusion coefficient in the MNNPCs electrodes (1.2 × 10−10 cm2 s−1) is about 22 times than that of reference electrode, suggesting excellent sodium ions diffusion kinetics in MNNPCs electrodes. In particular, MNNPCs are capable of delivering superior specific capacity of 394.5 mAh g−1 at 50 mA g−1 after 100 cycles with an initial coulombic efficiency of 58.7%. Such architecture provides a promising structural platform for the preparation of carbon anode materials for high reversible and high capacity sodium ions batteries.