CoAl2O4 nanoparticles (NPs) were synthesized using the sol–gel method and employed for the photocatalytic degradation of Direct Blue 129 (DB129) and Direct Red 31 (DR31) in an aqueous solution. The synthesized CoAl2O4 NPs have been fully characterized by X-ray powder diffraction (XRD), UV–vis diffuse reflectance spectroscopy (UV–vis DRS), Fourier transform infrared spectroscopy (FT-IR), scanning electron microscopy with an energy-dispersive X-ray spectroscope (SEM-EDS), transmission electron microscope (TEM), and Brunauer Emmett Teller (BET). The experiment investigated the optimal conditions for photocatalysis, including the amount of photocatalyst dosage, contact time, visible light irradiation, pH, and initial dye concentration. The results demonstrated that CoAl2O4 nanoparticles have great potential for efficiently photodegradation of direct blue 129 (DB129) and direct red 31 (DR31). Furthermore, the use of radical scavenger agents helped to clarify the mechanism by which the dyes are degraded through photodegradation.