Spinel ferrites with compositions MgxCo1−xFe2O4 (x = 0.0 to 0.7) were synthesized using the wet chemical co-precipitation method. The structural analysis confirmed crystallite sizes ranging from 14 to 27 nm, calculated via the Debye–Scherrer equation and Williamson-Hall method. Optical studies revealed that the band gap increased from 2.15 eV for undoped cobalt ferrite (CoFe2O4) to 2.31 eV for Mg0.5Co0.5Fe2O4, suggesting improved optical properties with Mg doping. Morphological investigations using ImageJ software showed a decrease in average grain size from 65 to 33 nm with higher Mg doping, accompanied by smoother surfaces. Photocatalytic tests demonstrated significant degradation of Methylene blue (MB) dye under visible light irradiation. Optimal degradation of 25 ppm MB dye was achieved using 0.200 g/L Mg0.5Co0.5Fe2O4 ferrites and 0.435 mM hydrogen peroxide (H2O2) at pH 10.5. The degradation followed first-order kinetics, emphasizing the material’s potential as an efficient photocatalyst. This work indicates the role of Mg doping in developing the structural, optical, and photocatalytic features of spinel ferrites as a promising candidate for environmental remediation applications in the form of Mg0.5Co0.5Fe2O4.