Wastewater discharge from the textile industry poses significant health problems for humans. As a result, the effluent waters are often rich in dyes, whose low natural decomposition capacity makes their treatment complex, thus contributing to environmental degradation. It becomes imperative to implement effective solutions for treating these contaminated waters, with a primary goal: to make them fit for human consumption. The present study focuses on the development of green TiO2 nanoparticles (TiO2-NP) using titanium (IV) isopropoxide as a precursor, along with the extract of Astragalus boeticus (A.B). These green TiO2 nanoparticles have been developed for use as highly efficient photocatalysts for the degradation of two types of dyes: Reactive Yellow 161 (RY161), an anionic dye, and Crystal Violet (CV), a cationic dye. The structural, microstructural, and optical properties of the synthesized material were characterized using XRD, FTIR, SEM, EDX, and UV-Vis methods. The results of these analyses revealed that the nanoparticles have a size of approximately 68 nm, possess an anatase structure, exhibit a spherical surface morphology, and have a band gap of 3.22 eV. The photocatalytic activity of the synthesized material demonstrated a 94.06% degradation of CV dye in a basic environment (pH = 10) within 30 min, with an initial CV concentration of 10 mg/L and a catalyst mass of 1 g/L. Additionally, it achieved a 100% degradation of RY161 dye in an acidic environment (pH = 4) within 90 min, with an initial RY161 concentration of 30 mg/L and a catalyst mass of 1 g/L. Furthermore, the recycling study indicated that the green TiO2 NPs catalyst could be effectively reused for up to five cycles. These experimental findings suggest that the developed TiO2 catalyst holds significant potential as an eco-friendly solution for remediating aqueous media polluted by both anionic and cationic dyes.