Sodium hypochlorite generator for wastewater treatment comprises an electrolyzer, electrodes, a power supply, a control system, a water softener, a chemical storage system, a brine system, a sodium hypochlorite generation system, and a chemical dosing system. Disinfection with this equipment is economical. It only needs salt and water to produce sodium hypochlorite solution upon power on, with low production costs and simple operation.