This work studied a low-cost, simple, and rapid biosynthesis of TiO2 nanoparticles (TiO2-NPs) by using aqueous extract of Centaurea cyanus (C. cyanus) plant as the reducing agent at ambient condition. The characterization of the synthesized TiO2-NPs was determined by various advanced techniques, including XRD, SEM, DLS, TGA, and BET analyzer. The XRD analysis showed an average crystallite size of 12.5 nm with an anatase phase. The SEM images showed that the synthesized TiO2-NPs possessed spherical shape and an average particle size of 14.5 nm. The DLS results indicated that the mean distribution size and surface charge of the nanoparticles are 11.5 nm and − 13 mV, respectively. The BET method indicated the average surface area, mean pore diameter size and pore size distribution of the biosynthesized TiO2-NPs as 62.4 m²/g, 8.86 nm and 1.21 nm, respectively. In addition, as a practical application, the study evaluated the photocatalytic activity of the biosynthesized TiO2-NPs on degradation of ketoconazole (KNZ) in aqueous solutions. In this regard, the effect of a number of important operational variables, including pH, TiO2-NPs dosage, and KNZ concentration and also the effect of H2O2, as an oxidant agent on the degradation process, were investigated and optimized. The photocatalytic degradation efficiency (DE) of 10 mg/L KNZ was 98.4% under the optimum condition of [TiO2-NPs] = 1600 mg/L, pH 3.5, T = 30 °C, [H2O2] = 120 mg/L, and 60 min. After five resuscitations and use of the green synthesized TiO2-NPs, it was observed that DE decreased by only less than 7.5%. The kinetics data evaluation showed that the KNZ photodegradation is consistent with the pseudo-first-order model with the rate constant (k) of 0.0.271 1/min. Furthermore, the KNZ photocatalytic degradation process was checked by determining the toxicity of the solution, the results of which showed that the toxicity of the KNZ solution decreased significantly after the photocatalytic degradation. Finally, t