Abstract The electrocoagulation (EC) process was developed to overcome the drawbacks of conventional wastewater treatment technologies. This process is very effective in removing organic pollutants including dyestuff wastewater and allows for the reduction of sludge generation. The purposes of this study were to investigate the effects of the operating parameters, such as pH, initial concentration ( C 0), duration of treatment ( t), current density ( j), interelectrode distance ( d) and conductivity ( κ) on a synthetic wastewater in the batch electrocoagulation–electroflotation (EF) process. The optimal operating conditions were determined and applied to a textile wastewater and separation of some heavy metals. Initially a batch-type EC–EF reactor was operated at various current densities (11.55, 18.6, 35.94, 56.64, 74.07 and 91.5 mA/cm 2) and various interelectrode distance (1, 2 and 3 cm). For solutions with 300 mg/L of silica gel, high turbidity removal (89.54%) was obtained without any coagulants when the current density was 11.55 mA/cm 2, initial pH was 7.6, conductivity wa s 2.1 mS/cm, duration of treatment was 10 min and interelectrode distance was 1 cm. The application of the optimal operating parameters on a textile wastewater showed a high removal efficiency for various items: suspended solid (SS) 86.5%, turbidity 81.56%, biological oxygen demand (BOD 5) 83%, chemical oxygen demand (COD) 68%, and color over 92.5%. During the EC process under these conditions, we have studied the separation of some heavy metal ions such as iron (Fe), nickel (Ni), copper (Cu), zinc (Zn), lead (Pb) and cadmium (Cd) with different initial concentrations in the range of 50–600 mg/L and initial pH between 7.5 and 7.8. This allowed us to show that the kinetics of electrocoagulation–electroflotation is very quick (<15 min), and the removal rate reaches 95%.