Textile dyeing wastewater was treated by electrocoagulation using aluminium and iron plate electrodes. Response surface methodology and central composite design were applied in the experiments and in statistical data analysis. A current density of 30–100 A m−2, an initial pH of 4–8, and an operating time of 10–40 min were chosen as independent variables, and the chemical oxygen demand, total organic carbon, and turbidity removal efficiencies and the operating cost were selected as responses in the electrocoagulation process. The developed quadratic models for the responses and the experimental data were in good agreement with model predictions statistically (R2 ≥ 0.92, Adj R2 ≥ 0.82, and Prob > F < 0.004). The optimised operating variables (initial pH, current density, and operating time) and the maximum total organic carbon, chemical oxygen demand, and turbidity removal efficiencies for textile dyeing wastewater were 5.5, 63.2 A m−2, 30.4 min, 77%, 82%, and 94% for the iron electrode and 5.6, 52.5 A m−2, 33.9 min, 68%, 69% and 99% for the aluminium electrode respectively. Minimum operating costs for the iron and aluminium electrodes under optimum conditions were €2.1 m−3 (€1.0 kg−1 COD) and €2.4 m−3 (€1.6 kg−1 COD). The iron electrode was found to be superior to the aluminium electrode in terms of removal efficiencies and operating cost for the treatment of textile dyeing wastewater.