A new metal-free O-doped and pyridine-grafted g-C3N4 (OCN/Py) was prepared and used to degrade tetracycline (TC) with peroxymonosulfate (PMS) as oxidant under visible light irradiation. Doping of O and graft of Py into CN framework could enhance the separation of photogenerated charge carriers, the adsorption of PMS and TC, as well as PMS activation. Experiments and theoretical calculations confirmed that the OCN/Py-PMS* complex was formed and mediated electron transfer for degrading TC. In addition, the ⋅O2−, •OH, surface-bound SO4•−, 1O2, especially holes contributed to TC removal. 97.0 % TC was degraded after 60 min visible light irradiation in the presence of 0.16 g L–1 OCN/Py and 0.5 mM PMS. The corresponding total organic carbon removal ratio and apparent rate constant were 97.37 % and 0.0568 min−1, respectively. This work provides an effective way to change CN structure for boosting TC degradation, and gives deep insights for the relationship among photogenerated charge separation, PMS activation and TC degradation.