Metal-organic frameworks (MOFs)-derived heteroatom-doped carbon-based catalysts are commonly used in sewage treatment. However, the challenge lies in developing a simple route for heteroatom co-doping of MOFs-derived porous carbon that efficiently degrades organic pollutants without the need for additional post-treatment procedures. Herein, built-in Co nanoparticles are integrated with S,N-codoped porous carbon through a straightforward in situ co-doping strategy using ZnS nanoparticles as templates and a sulfur source. This approach simplifies the process of achieving S,N-codoping of zeolitic imidazolate frameworks-derived carbon without requiring extra nitrogen and sulfur sources or post-treatment procedures. The resulting Co@SNPC-900 catalyst demonstrates high catalytic performance in degrading tetracycline (TC) via peroxymonosulfate (PMS) activation, showing a removal efficiency of 97% in 30 min and excellent cycling stability. Furthermore, the Co@SNPC-900/PMS system shows strong resistance to changes in solution pH, interference from inorganic ions, and humic acid. The synergistic effects between S and N co-doping contribute to the formation of dominant non-radical pathways for boosting TC degradation. The study also elucidates three reaction pathways and identifies including sixteen intermediates with lower toxicity. This research presents a straightforward in situ co-doping strategy for producing highly active and durable built-in metal nanoparticles integrated porous carbon catalysts for environmental remediation.