Graphitic carbon nitride (g-C3N4) is a metal-free heterogeneous catalyst that has attracted attention because of its good chemical stability, cost-effectiveness, and environmental friendliness. In the work presented herein, F,O,S-codoped carbon nitride was synthesized by heating a mixture of melamine cyanurate and trifluoromethanesulfonic acid at 550 °C for 50 min. The obtained product was characterized by transmission electron microscopy, infrared spectroscopy, X-ray powder diffraction, CHNS elemental analysis, total combustion-ion chromatography, X-ray photoelectron spectroscopy, scanning electron microscopy coupled with energy-dispersive X-ray spectroscopy, and UV-Vis spectroscopy. Results point to an F,O,S-codoped g-C3N4. The material was applied as a photocatalyst for the formation of benzoxazoles and benzimidazoles by condensation–aromatization of 2-aminophenol or 1,2-phenylenediamine with suitable aldehydes (viz. benzaldehyde, 4-chlorobenzaldehyde, 2-naphthaldehyde, 2-hydroxybenzaldehyde, and 2-methoxybenzaldehyde), obtaining yields of up to 90% in 15 min under visible light irradiation, with good selectivity and reusability. Thus, the reported findings suggest that this F,O,S-codoped g-C3N4 may hold promise as a metal-free photocatalyst for the rapid synthesis of 2-arylbenzoxazoles and 2-arylbenzimidazoles.