To solve the pollution of natural water bodies by organic dyes and the exceeding of indoor HCHO standards caused by renovation, the study realized the band gap modulation of g-C3N5, a novel semiconductor photocatalytic material, by using H3BO3 as a source of nonmetallic B. The prepared B/g-C3N5 has shown excellent photocatalytic performance and stability for organic dye degradation in water bodies and indoor HCHO removal. The degradation rate of methylene blue (MB) reached 95% in 60 min of visible light, and the removal rate of HCHO reached 96.3% in 180 min of visible light. The MB and HCHO were efficiently degraded to small molecule inorganic compounds such as CO2 and H2O under the oxidation of active groups such as ·O2 − and h+. The doping of nonmetallic B realizes the efficient separation of e−-h+ of g-C3N5, improve the absorption performance of visible light, and broaden the spectral range significantly. The modulation of the g-C3N5 band gap provides a potential application scenario for the development of novel photocatalytic materials.