A three-dimensional nitrogen-doped carbon framework (NCF) has been synthesized by annealing a zeolitic imidazolate framework (ZIF-67), followed by removing the residual metal ions. The NCF shows a polyhedral outline with strong interconnected hollow nanospheres as its subunits. It is highly porous, with a large surface area of 623 m2 g−1, and a high nitrogen content of 12.3 wt%. When applied as an anode material for a sodium ion battery, the NCF exhibits an excellent electrochemical performance with a high reversible capacity (327 mA h g−1, and stable at 300 mA h g−1), good cycling stability, and excellent rate capability (175 mA h g−1 at 2000 mA g−1). The presence of N in the NCF is believed to provide more active sites for enhancing the electrochemical performance, and provide more defects and nanovoids to trap more Na+ ions.