Phosphorus-doped hard carbon nanofibers with macroporous structure were successfully synthesized by electrospinning followed by a thermal treatment process using polyacrylonitrile and H3PO4 as carbon and phosphorus precursors, respectively. X-ray photoelectron spectroscopy analysis reveals that the doped phosphorus atoms can incorporate into the carbon framework and most of them are connecting with carbon atoms to form P-C bond. The (002) plane interlayer spacing was taken from the X-ray diffraction pattern, which shows a large spacing of 3.83 Å for the obtained P-doped hard carbon nanofibers. When used as an anode in sodium-ion batteries, the as-prepared P-doped hard carbon nanofibers can deliver a reversible capacity of 288 and 103 mAh g-1 at a current density of 50 mA g-1 and 2 A g-1, respectively. After 200 cycles at 50 mA g-1, the capacity retention of P-doped hard carbon nanofibers still reaches 87.8%, demonstrating good cycling durability. These excellent electrochemical performances of P-doped hard carbon nanofibers can be attributed to the macroporous structure, large interlayer spacing, and the formation of P-C bond.