The present invention provides a gas generator comprising an electrolytic cell, a gas pathway, and an ozonator. The electrolytic cell is configured for electrolyzing the electrolyzed water to generate the gas with hydrogen. The gas generated from the electrolytic cell is transferred by the gas pathway for human to inhale. The ozonator is connected to the gas pathway for generating ozone to enter the gas pathway. The present invention uses the ozonator to generate ozone for cleaning the gas pathway, thereby providing a pure gas with hydrogen.