Abstract Boron-doped biochar (B-BC) was synthesized by pyrolysis using solid waste of sorghum straw as raw material. The specific surface area of B-BC increased significantly by 2.38 times compared to that of pure BC. This enhancement allowed B-BC (0.3 g L −1 ) to achieve complete adsorption of 10 mg L −1 tartrazine (TTZ) within 40 min. Moreover, acidic conditions were more favorable for TTZ adsorption, achieving complete removal of TTZ in only 15 min at a pH of 3.0. Interestingly, the adsorption rate of TTZ by B-BC in the presence of 0.05 M Cl − was approximately 2.12 times higher than that in the absence of Cl − . When other background electrolytes were present, excluding PO 4 3− , complete adsorption of TTZ could also be achieved within 60 min. Thermodynamic analysis and DFT calculations described the parameters of B-BC for TTZ adsorption, including $$\Delta {\text{G}}^{\Theta }$$ ΔGΘ (< 0 kJ mol −1 ), $$\Delta {\text{H}}^{\Theta }$$ ΔHΘ (− 2.199 kJ mol −1 ), $$\Delta {\text{S}}^{\Theta }$$ ΔSΘ (− 6.068 J mol −1 K −1 ), and the adsorption energy ( E ads = − 0.6919 eV), indicating a tendency towards a spontaneous adsorption process. Moreover, the strong electron transfer ability of B-BC and the oxygen-containing groups promoted the activation of PDS and generation of active substances such as 1 O 2 , O 2 •− , and SO 4 •− , thereby degrading TTZ into products with lower biological toxicity. When the added PDS was only 0.1 mM, the degradation rate constant of TTZ could reach 0.1481 min −1 . Furthermore, boron doping enhanced the stability of biochar, enabling the complete removal of 10 mg L −1 TTZ even after recycling and regeneration. In summary, this study offers a practical solution for the resource utilization of solid waste sorghum straw and the treatment of TTZ-polluted wastewater. Graphical Abstract