Fe 2 O 3 is regarded as a promising anode material for lithium-ion batteries (LIBs) and sodium-ion batteries (SIBs) due to its high specific capacity. The large volume change during discharge and charge processes, however, induces significant cracking of the Fe 2 O 3 anodes, leading to rapid fading of the capacity. Herein, a novel peapod-like nanostructured material, consisting of Fe 2 O 3 nanoparticles homogeneously encapsulated in the hollow interior of N-doped porous carbon nanofibers, as a high-performance anode material is reported. The distinctive structure not only provides enough voids to accommodate the volume expansion of the pea-like Fe 2 O 3 nanoparticles but also offers a continuous conducting framework for electron transport and accessible nanoporous channels for fast diffusion and transport of Li/Na-ions. As a consequence, this peapod-like structure exhibits a stable discharge capacity of 1434 mAh g -1 (at 100 mA g -1 ) and 806 mAh g -1 (at 200 mA g -1 ) over 100 cycles as anode materials for LIBs and SIBs, respectively. More importantly, a stable capacity of 958 mAh g -1 after 1000 cycles and 396 mAh g -1 after 1500 cycles can be achieved for LIBs and SIBs, respectively, at a large current density of 2000 mA g -1 . This study provides a promising strategy for developing long-cycle-life LIBs and SIBs.