FeP2 and P are promising anode material for lithium and sodium ion storage, due to the high theoretical capacity. However, poor electric conductivity and severe volume expansion limit its actual performance. Herein, we prepared a flexible self-supporting anode material which is consist of FeP2, P and C heterostructure nanofibers with diameter of 150.0–200.0 nm named FeP2@CNs-700. Here, well-dispersed FeP2 nanoparticles and amorphous phosphorus are confined in carbon nanofiber skeleton, which enhance the material's electron/ion transport and structure stability. As a result, The FeP2@CNs-700 exhibits a high capacity (1132.2 mAh g − 1 at 0.1 A g − 1 for lithium ion batteries, 680.8 mAh g − 1 at 0.1 A g − 1 for sodium ion batteries), excellent cycle stability (a capacity retention of 84.6% at 0.5 A g − 1 after 500 cycles for LIBs, 300.1 mAh g − 1 at 1.0 A g − 1 after 400 cycles for SIBs), outstanding rate performance (461.2/227.9 mAh g − 1 at high current density of 10.0 A g − 1 for Li/Na-ion battery, respectively) and high initial coulombic efficiency (87.3% for LIBs and 74.5% for SIBs), indicating a promising candidate for high capacity anodes.