g-C3N4 (CN), a nonmetal semiconductor, shows tremendous potential for utilization in the field of photocatalysis owing to its physicochemical stability and good visible light response properties. In this study, the photocatalyst of O-g-C3N4 (OCN) coupled with SnO2 (SO) was synthesized and its photocatalytic performance was evaluated under simulated sunlight irradiation for rhodamine B (RhB) degradation and Cr(IV) reduction. The structure, morphology, and properties of the synthesized photocatalyst were investigated using X-ray diffraction, Brunauer–Emmett–Teller analysis, transmission electron microscopy, X-ray photoelectron spectroscopy, Fourier transform infrared spectroscopy, ultraviolet–visible diffuse reflectance spectroscopy, and an electrochemical system. The analysis results revealed that the 30-SO/OCN nanocomposite exhibited an excellent specific surface area; moreover, O atoms were doped into CN and a heterojunction was formed between SO and OCN. The 30-SO/OCN nanocomposites exhibited more than 2.52 and 1.73 times catalytic activity than 30-SO/CN nanocomposites toward RhB and Cr(IV) degradation, respectively. Based on radical scavenger experiments, h+ and e− were confirmed to be the main active species in the photocatalysis of 30-SO/OCN nanocomposites. The excellent photocatalytic activity of 30-SO/OCN nanocomposites was attributed to the special surface of OCN as well as the formation of a heterojunction between SO and OCN. Therefore, the 30-SO/OCN nanocomposites were confirmed to be highly active and reliable water-treatment photocatalysts. © 2022 Elsevier B.V.