Nitrogen-doped porous carbon (NPC) catalysts show potential for activating peroxymonosulfate (PMS) to treat water pollution. However, nitrogen (N) experiences significant loss during pyrolysis, posing challenges for synthesizing N-rich carbon catalysts. This study innovatively proposed a molecular confinement strategy using the C−S−C bond formed between graphitic carbon nitride and mercaptan. Under this confinement, we successfully synthesized NPC-15 with a high N content (21.4 at%), surpassing most catalysts reported in the literature. NPC-15/PMS system showed excellent performance in degrading bisphenol A (BPA), achieving complete degradation within 3 min (kobs = 1.771 min−1), surpassing the effectiveness of most previously reported catalysts. The NPC-15/PMS system exhibited excellent performance and stability under various conditions, reducing BPA toxicity to ecological and human embryonic kidney cells. Moreover, it maintained stability during long-term continuous operation in a fixed-bed reactor, showing promise for practical applications. Through experiments and theoretical calculations, the mechanism of NPC-15 activating PMS was comprehensively investigated. The NPC/PMS system operated via a dual non-radical pathway involving singlet oxygen and electron transfer process induced by pyridinic N and graphitic N dual active sites. Pyridinic N promoted the generation of 1O2, while graphitic N supported the electron transfer process. This study introduced a new strategy for the preparation of N-rich carbon catalysts and proposed a novel method for the removal of emerging pollutants in water.