There is provided an X-ray diffraction apparatus configured to irradiate a sample S on a sample stand with X-rays generated from an X-ray source and detect the X-rays diffracted by a sample using a detector, including a virtual mask setting section and a signal processing section. The detector outputs detection signals according to intensity of the X-rays received by detection elements, for each of the plurality of detection elements forming a detection surface. The virtual mask setting section is capable of setting a virtual mask on the detection surface of the detector, and setting at least an opening dimension of the virtual mask as an opening condition of the virtual mask independently in an X direction and a Y direction. The signal processing section processes the detection signals outputted from the detector according to the opening condition of the virtual mask set in the virtual mask setting section.