The growing environmental challenge posed by the persistence of tetracycline (TC) antibiotics in natural waters is of increasing concern. To address this, there is an imperative need for advanced methods to mitigate TC residues. Herein, we demonstrate the preparation of nitrogen-doped graphitic carbon nitride integrated with magnetic Fe3O4 (N-g-CN/Fe3O4) composites, showcasing narrow band gaps optimized for TC degradation. These advanced materials, conceived through a thermal poly-condensation approach, utilize citric acid and melamine as precursors for nitrogen and g-CN, respectively. These composites exhibit a face-centered cubic architecture, with particle dimensions between 8 to 12 nm and encompassing both meso and microporous structure. The results of the Brunauer–Emmett–Teller analysis indicated specific surface areas of 6.73 m²/g for g-CN, 69.80 m²/g for N-g-CN, 62.55 m²/g for Fe3O4, and 148.32 m²/g for N-g-CN/Fe3O4. These values demonstrate an increase in surface area upon the incorporation of heteroatom of nitrogen and Fe3O4, into the g-CN matrix, thus influence the photocatalytic performance. Under solar light exposure, the synthesized photocatalysts demonstrated photocatalytic activity with a degradation efficiency of 94.16 % within 120 min. Specifically, the N-g-CN/Fe3O4 (22.5 %) composites exhibited remarkable photocatalytic efficiency due to the narrow band gap energy between N-g-CN and Fe3O4, enhanced light absorption in the visible range, and effective charge carrier separation and transportation to the pollutants. N-g-CN/Fe3O4 (22.5 %) composites demonstrated good recyclability (five cycles), magnetic sustainability, and stability for the degradation of TC and emerging pollutants from wastewater using photocatalysts. Similarly, FGCN composites exhibited good recyclability (five cycles), magnetic retrievability, and stability for degrading organic and emerging pollutants from wastewater through photocatalysis. This efficiency can be attributed to the harmonious combination of nitrogen doping, refined surface area, and the natural heterojunction between N-g-CN and Fe3O4.