Polymeric carbon nitride (PCN) has become the most promising metal-free photocatalysts but its activity is low. Molecule doping of PCN has been proved to be an effective strategy to achieve high photocatalytic performance. Herein, we report a bottom-up method to synthesize modified PCN, which includes 2,5-dibromopyrazine doping, thermal-induced exfoliation and condensation/polymerization. The incorporation of electron-deficiency 2,5-dibromopyrazine into the PCN framework can effectively tune the electronic structures and improve the charge-carrier separation. In addition, the incorporation of 2,5-dibromopyrazine induced significant structural changes from planar symmetric to distortion. The optimized pyrazine doped PCN showed a reaction rate enhancement of 4-fold for the degradation of sulfamethazine compared to that of conventional urea-based PCN. Further reactive species and degradation intermediate detection studies, indicated that O2− was generated during the photocatalytic process, which could lead to the decomposition, and finally mineralization of sulfamethazine. 2,5-Dibromopyrazine doped PCN also leads to a 6.3-fold improvement in H2 generation with the visible light. Especially, phytotoxicity experiments showed that the toxicity of sulfamethazine after degradation is greatly reduced, and the as-prepared photocatalyst is environmentally friendly.