Sol-gel synthesis of W-doped TiO2 nanoparticles (W-TiO2) as a photocatalyst for Procion Red MX-5B (MX-5B) azo dye treatment in textile wastewater was the main focus of this research. Scanning electron microscopy (SEM), X-ray diffractometer (XRD), X-ray photoelectron spectroscopy (XPS), and energy dispersive spectroscopy (EDS) structural studies of nanostructured photocatalysts showed that W was successfully incorporated into the TiO2 lattice. According to EIS investigations, W-TiO2 has a greater rate of charge transfer and excellent charge separation capabilities compared to a sample of pure TiO2. It shows the W-TiO2 nanostructured photocatalyst sample's exceptional photocatalytic performance. The band gap energies of TiO2 and W-TiO2 were determined through optical studies to be 3.22 eV and 2.93 eV, respectively, showing an improvement in the photocatalytic activity of TiO2 in the visible light domain. Studies of the photocatalytic performance indicated that the full treatment of MX-5B molecules was achieved after 105, 100, 95, 80, 70, 85, and 90 min of exposure to visible light for pure TiO2, W0.5-TiO2, W1-TiO2, W3-TiO2, W5-TiO2, W8-TiO2, and W10-TiO2, respectively. These studies revealed the great and quick photocatalytic treatment of MX-5B in the presence of doped TiO2. The results of a study that used 400 mL of a 40 mg/L MX-5B solution prepared with deionized water as a control sample and a sample of actual textile wastewater as a real sample showed that MX-5B from actual textile wastewater was effectively photocatalytically degraded in the presence of W5-TiO2 photocatalyst.