• Chemical blowing method can optimize the photocatalytic activity of g-C 3 N 4 . • Electrostatic action promotes the adsorption of moxifloxacin on 2D-g-C 3 N 4 . • Degradation pathways and products of moxifloxacin were elaborated. • Usability of 2D-g-C 3 N 4 was promising in actual environment. Residuals of antibacterial drugs (ADs) threaten human health and ecological equilibrium, whereas few efficient treatments have been developed. Using a photocatalyst of two-dimensional (2D) g-C 3 N 4 nanosheets (CNNS) fabricated by the method of ammonium chloride assisted chemical blowing, a high-efficiency photocatalytic treatment was reported to eliminate moxifloxacin (MOX) as a fourth-generation quinolone. The characterization results indicated that the high activity of CNNS originated from its 2D morphology, large specific surface area and high separation efficiency of photogenerated charges. Furthermore, the photocatalyst dosage, MOX concentration and the pH of solution were optimized. Based on the detection of reactive oxygen species (ROS) and intermediates in the photocatalytic process, the plausible photocatalytic mechanism and the degradation pathways of MOX were proposed. The toxicity assessment implied that antimicrobial activity of the photocatalytic degradation products were weakened significantly. The synthetic CNNS demonstrated excellent stability and reusability during five cycles. Finally, we carried out photocatalytic degradation experiments in the simulated real scenarios of tap water, lake water and sunlight. This work suggested the CNNS had great potential for purifying ADs-containing wastewater.