Disinfection is an essential step to keep humans healthy from microorganisms present in drinking water. However, the formation of disinfection by-products (DBPs) is associated with adverse health effects, and the presence of organic pollutants in groundwater results in even more detrimental effects. Therefore, a better treatment technique is required to disinfect and remove organic pollutants simultaneously to control the formation of DBPs. Electro-chlorination (EC) was carried out using graphite electrode at the current density of 0.54–1.09 mA/cm2 and sodium chloride for in-situ hypochlorite generation to treat groundwater contaminated with phenol and aniline. The comparative study between chlorination and EC showed a significant level of oxidation of phenol and aniline, resulting in their reduction up to 98.48% and 99.47%, respectively, in the EC process. Due to the higher mineralization rate of aniline, both chlorination and EC method are found to be effective. However, only the EC method is found to be appropriate and effective for treating phenol-contaminated water as the chlorination method resulted in the formation of complicated phenolic by-products. Gas-Chromatography/Mass-Spectrometry (GCMS) was used to assess the by-product formation of chlorination and EC in contaminated groundwater through the full-scan.