Hydrogen gas (H2) produced by water splitting using renewable energy, namely green hydrogen, is the most promising energy carrier of the low-carbon economy1–6. However, the geographic mismatch between renewables distribution and freshwater availability poses a significant challenge to green hydrogen production7–9. Here, we demonstrate a method of directly producing H2 from the air, namely, capturing freshwater from the atmosphere using hygroscopic electrolyte and converting it to H2 by electrolysis powered by solar energy. A prototype H2 generator has been successfully established and operated for 12 consecutive days with a stable performance at an average Faradaic efficiency around 95%. This so-called direct air electrolysis (DAE) module can work under low relative humidity (20%) environment, overcoming water supply issues and producing green hydrogen sustainably with minimal impact to the environment. The DAE modules can be easily scaled to provide H2 to remote, arid/semi-arid, and scattered areas.