Na4Fe3(PO4)2(P2O7) (NFPP) is an attractive candidate for Na+ batteries (SIBs) and Li+ batteries (LIBs). However, the real implementation of NFPP has been critically restrained by the inferior intrinsic electronic conductivity. Herein, in situ carbon-coated mesoporous NFPP, obtained via freeze drying and heat treatment, demonstrates highly reversible insertion/extraction of Na+/Li+. Mechanically, the electronic transmission and structural stabilities of NFPP are significantly enhanced by the graphitized carbon coating layer. Chemically, the porous nanosized structure shortens Na+/Li+ diffusion paths and increases the contact area between the electrolyte and NFPP, ultimately rendering fast ion diffusion. Greatly, long-lasting cyclability (88.5% capacity retention for over 5000 cycles), decent thermal stability at 60 °C, and impressive electrochemical performances are demonstrated in LIBs. The insertion/extraction mechanisms of NFPP in both SIBs and LIBs are systematically investigated, confirming its small volume expansion and high reversibility. The superior electrochemical performances and the insertion/extraction mechanism investigation confirm the feasibility of utilizing NFPP as a cathode material for Na+/Li+ batteries.