The true potential of Mg–S batteries is not yet realized despite its great advantages in material cost and safety. This is due to the lethargic reaction kinetics involved in the dissociation of Mg polysulfide (MgPS) on the cathode. Herein, we propose nitrogen–doped mesoporous carbon (NdMC) materials with suitable nitrogen content and surface moieties that can be utilized as catalytic hosts to enhance polysulfide fragmentation and electron access to the redox active sites in Mg–S batteries. In controlled NdMC, the surface nitrogen atoms located at the pyridinic positions can strongly bind MgPS and accelerate the reduction of MgPS to MgS, while the graphitic wall structure facilitates facile electron transport to the reaction sites. This synergic effect enables the composite electrode made of tuned NdMC and sulfur to exhibit an enhanced reversible capacity and good cycling capacity retention in Mg–S batteries. This study offers a new strategy for improving the performance of Mg–S batteries by fine-tuning the structural properties of the carbon hosts.