Lithium–sulfur batteries hold great promise as energy storage systems, but the shuttle effect of lithium polysulfides (LiPS) and large volume variation limit their capacity and cycle life. We have developed CoFe alloy wrapped in N-doped porous carbon spheres (e-CF@NC) with a core–shell structure through simple copolymerization and pyrolysis. The nitrogen-doped porous carbon shell provides electron and ion transport channels and more active sites for electrolyte ion adsorption. The high chemically stable carbon can limit the segregation of polysulfides, further improving the battery cycling stability. Besides, the inside CoFe alloy particles catalyze the conversion between LiPS and Li2S, speeding up reaction kinetics and reducing solvation of active sites. Consequently, lithium–sulfur batteries with e-CF@NC-2 as the cathode display a high initial specific capacity of 1146 mA h g−1 at 0.1 C, excellent rate performance (891 mA h g−1 at 1 C, 741 mA h g−1 at 2 C), and satisfied cycle stability (average capacity decay rate of 0.033% per cycle at 1 C for 300 cycles), demonstrating significant application potential.