In situ ambient-pressure X-ray photoelectron spectroscopy (AP-XPS) combined with resistivity measurement was performed for a Pt thin-film H2 gas sensor. We experimentally demonstrate that the chemical state of the Pt surface changes under working conditions, and it directly links to the sensing performance. Moreover, the operating principle is discussed at the atomic scale.