The globe is experiencing freshwater scarcity resulting from untreated effluents entering freshwater streams. Developing cost-effective materials to treat industrial effluents before entering freshwater is crucial. Herein, K2BaCoO3 (KBCO) perovskite nanomaterials of naturally abundant, nontoxic, eco-friendly elements were synthesized through a facile hydrothermal synthesis route. Various characterization techniques were used to investigate the synthesis of the resulting material. The SEM images of the synthesized catalyst reveal irregular morphology and rough surfaces. FTIR and EDX analyses confirmed the successful synthesis of KBCO while TEM analysis revealed a polycrystalline nature with an average crystallite size of 13nm. At optimum conditions (50min sunlight irradiation, 0.015g KBCO, 40mg L−1 MB dye and pH 11), 99.08% MB dye degradation was observed. The reaction kinetics fits the first-order kinetic model with R2 values of 0.99. The photocatalysis was statistically optimized/validated by analysis of variance (ANOVA) Box–Behnken design of the response surface methodology (RSM). The predicted R2 of 0.84 is in reasonable agreement with the adjusted R2 of 0.99; adequate precision of 347.86 indicates an adequate signal which shows that the model can be used to navigate the design space. The model F value is 15414.00, while the p-value of more than ten terms is less than 0.05, indicating the significance of the model. A standard deviation of 0.32, and no significant lack of fit of 2.41 confirms it as the best-fitted model.