The present invention provides a gas generator includes a water tank, an electrolysis device, a condensate filter, a humidification device, and a pump device. The electrolysis device is coupled to the water tank to electrolyze electrolyzed water accommodated in the water tank to generate a hydrogen-oxygen mixed gas. The hydrogen-oxygen mixed gas is condensed and filtered out electrolyte in the hydrogen-oxygen mixed gas by the condensate filter to generate a filtered hydrogen-oxygen mixed gas. The humidification device accommodates supplementary water and is connected to the condensate device for humidifying the filtered hydrogen-oxygen mixed gas. The supplementary water is pumped back to the water tank from the humidification device by the pump device; therefore, the electrolyte absorbed in the condensate filter is flushed back to the water tank for reducing the consumption of the electrolyte.