CoFe2O4 nanostructures were first synthesized via a simple and high-quality hydrothermal method. Strontium titanate (SrTiO3) nanoparticles were then prepared using the sol-gel method. In the last step, magnetic and photocatalytic nanocomposites of CoFe2O4–SrTiO3 and SrTiO3: N–CoFe2O4 were synthesized successfully also by sol-gel method. To characterize the purity, morphology, and particle size of nanomaterials, X-ray diffraction (XRD), scanning electron microscopy (SEM) and Fourier transform infrared (FT-IR) spectroscopy, were employed. Vibrating sample magnetometer (VSM) studies show the super-paramagnetic and ferromagnetic property of the cobalt ferrite nanostructures. Photocatalytic activity of SrTiO3, SrTiO3: N nanoparticles and nanocomposites were evaluated using UV–Vis spectroscopy for degradation of acid brown and acid black (azo dyes) under ultraviolet and visible light. The CoFe2O4–SrTiO3 nanocomposites can lead to efficient charge separation and as a result having photocatalytic activity higher than SrTiO3 nanoparticles under UV light. By nitrogen doping to the SrTiO3 nanoparticles, this photocatalyst is activated with visible light because maximum point of the valence band will be transferred to the lower potential and energy gap is decreased. Due to the separation of charge compared to the SrTiO3: N nanoparticle, the SrTiO3: N–CoFe2O4 nanocomposite has high photocatalytic efficiency for destroying of pollutants.