In this research, Sn-doped TiO2 (Sn–TiO2) nanoparticles were synthesized by a simple sol–gel method. The structure and composition of the as-prepared sample were investigated using X-ray diffraction (XRD), Fourier transform infrared spectroscopy (FTIR), X-ray photoelectron spectroscopy (XPS) and ultraviolet–visible absorption spectroscopy. Electrophoretic deposition (EPD) technique was used to deposit thin films of Sn–TiO2 on 316L stainless steel (316L SS) substrate. In order to achieve a fine and high-quality layer on the electrode surface, N-phenyl-p-phenylenediamine (NPPDA) was used as a new dispersant and charging agent in ethanolic suspensions. Based on zeta potential and conductivity measurements of the suspensions, an optimum concentration of the NPPDA dispersant was found to be 3.0 g l−1. The in-situ EPD kinetics was also studied. The prepared Sn–TiO2 film was used for the photodegradation of methylene blue (MB) under UV, visible and sun lights. The results revealed that the Sn–TiO2 film could be able to degrade the MB under sunlight. The calculated degradations were 44, 65, and 73% after 2, 4 and 5 h, respectively. The relation between ln A0 A and time was linear, so it was proved that the photocatalytic degradation of MB can be characterized by pseudo-first order reaction kinetics.