A series of vanadium oxide thin films with different layer thicknesses were prepared by the sol–gel process. These V2O5 thin films exhibited excellent gasochromic performance with color change from yellow to gray/black on exposure to hydrogen gas and fast response rate under ambient condition. The structure and morphology of the films were investigated by X-ray powder diffractometer and scanning electron microscope. The H2 gasochromic property and the optical transmittance change of colored and bleached films were characterized by UV–visible spectrophotometer. Further, the gasochromic effect and the coloration mechanism of these films were investigated in detail by X-ray absorption spectroscopy. The investigations demonstrated that due to insertion of hydrogen ions, the valence state of vanadium varied from 4.8+ to 4.1+ and a distortion was observed in the structural symmetry of VO6 octahedron.