We present a simple method to measure the spatial coherence of hard x-ray beams. Based on the convolution of Gaussian functions, we analyze the diffraction patterns of a grating irradiated by partially coherent hard x rays with a constrained beam diameter. The spatial coherence properties of an x-ra