The carbon/boron co-doped TiO2 (CBCT) photocatalyst was produced through the gel-hydrothermal process in this study. Its properties were then analyzed by using XRD, FE-SEM, EDX, FTIR, BET and Raman techniques, according to which the CBCT had the dominant anatase phase, whereas its specific surface area (46.1 m2/g) and porosity (0.101) made it a suitable photocatalyst. The response surface methodology (RSM) was then employed to design an experiment to study the effects of pH, initial 4-nitrophenol concentration, irradiation time, irradiation intensity, and nanocatalyst concentration on the 4-nitrophenol removal efficiency. Based on the proposed experiments by the RSM, the highest removal efficiency (99.8%) was reported at a pH of 3.6, an initial 4-nitrophenol concentration of 20 mg/L, an irradiation time of 50 min, an irradiation intensity of 60 W, and a nanocatalyst concentration of 0.4 g/L. Increasing pH and pollutant concentration decreased removal efficiency; similarly, increasing nanocatalyst concentration, irradiation time, and intensity reduced removal efficiency. The photocatalytic removal of 4-nitrophenol was performed in the presence of 1% v/v of H2O2. Finally, the 4-nitrophenol removal efficiency was modeled based on the five designated parameters.