X-ray absorption spectroscopy (XAS) is a widely used characterization technique to explore the local geometric and electronic structures of materials with element specificity. XAS measurements are performed at synchrotron radiation sources that provide brilliant, tunable, and monochromatic energy photons. The advantages of XAS include good elemental, chemical, and orbital sensitivities, which all stem from inherent electron excitation and transition processes. XAS is categorized into soft (<2000 eV) and hard (>5000 eV) x-ray regimes, based on the incident photon energy. Soft x-rays can probe the K-edges of low-Z (atomic number) elements, including Li, C, N, O, and F, and the L-edges of 3d transition metals, whose K-edge is within the hard x-ray regime. All of these elements are essential components of energy materials. This article introduces the principle of XAS and reviews some recent applications in energy storage and energy conversion, illustrating the capabilities of XAS to investigate the fundamental properties of materials from the points of view of atomic and electronic structures, which play crucial roles in understanding the reaction mechanisms in high-performance devices.