An artificial neural network (ANN) model was developed for the photocatalytic degradation of rhodamine B by TiO2 nanoparticles synthesized by the electrochemical method, under direct sunlight irradiation. The four inputs are: irradiation time, initial dye concentration, pH of the initial solution, and catalyst loading. The ANN model with 20 hidden neurons and with R2 of 0.999 shows minimum values of the performance metrics of 0.169, 2.020, 1.531, and 0.215 for the mean square error, the root mean square error, the mean absolute error, and the mean absolute percentage error, respectively. The optimized ANN configuration of 4‐20‐1 shows a good fit with the experimental data. The result shows that the sunlight irradiation time has the main impact on rhodamine B degradation at ∼55 %.