This study aimed to prepare a biochar-modified iodine-doped titanium dioxide composite photocatalyst (B/I-TiO2) via hydrothermal reaction and evaluate its performance in sulfamethoxazole (SMX) degradation under simulated sunlight. Biochar was prepared from four agricultural wastes using hydrothermal and pyrolysis technologies, resulting in 3–30 graphite layers with a d-spacing of 0.35 nm. Hydrothermal activation transformed the disordered structure into a graphite microcrystalline structure, producing biochar with a quasi-three-dimensional graphene structure. Doping with 1–15 wt% of this biochar shifted the characteristic wavelength of B/I-TiO2 to 423–426 nm and increased the specific surface area by 1.25–1.94 times. The 5LB700H2I1T composite photocatalyst found the highest SMX removal efficiency of 40 %, and the 5WB900H2I1T composite photocatalyst found the highest SMX photodegradation efficiency of 30 %, respectively, irradiated with simulated sunlight of 3 hours. The wavelength redshift and degradation performance enhancement primarily resulted from iodine doping and the biochar's excellent crystallinity and high surface area. SMX removal was achieved through adsorption and photodegradation, with hydroxyl radicals and electron holes playing a significant role compared to superoxide radicals.