The valence state of Yb ions in beta-YbAlB4 and its polymorph alpha-YbAlB4 has been investigated by using X-ray absorption and emission spectroscopy in SPring-8 at temperatures from 2 to 280 K. The observed Yb valence is 2.78 +- 0.01 in beta-YbAlB4 at 2 K by using the X-ray emission spectroscopy. The valence is found to gradually increase with increasing temperature toward the trivalent state, and the characteristic temperature of the valence fluctuation is expected to be about 290 K. We also found a small increase in the Yb valence (~0.002) by applying a magnetic field of 32 T at 40 K to beta-YbAlB4.