A wavefront measuring apparatus includes an optical element forming a periodic pattern by light, a detector having pixels to detect the light, and a computer computing, based on detection results of the detector, wavefront information at positions in a wavefront of the light transmitted through or reflected by a specimen. The detector detects a first periodic pattern formed by the light, and a second periodic pattern formed by the light and shifted in phase from the first periodic pattern. The computer computes the wavefront information at one of the positions by using a result detected in a first pixel of the pixels when detecting the first periodic pattern, a result detected in a second pixel of the pixels when detecting the first periodic pattern, the second pixel being positioned within three pixels from the first pixel, and a result detected in the first pixel when detecting the second periodic pattern.