Material properties frequently relate to structures at or near surfaces, particularly in thin films. As a result, it is essential to understand these structures at the molecular and atomistic levels. The most accurate and widely used techniques for characterizing crystallographic order are based on X-ray diffraction. When dealing with thin films or interfaces, standard approaches, such as single crystal or powder diffraction, are not suitable. However, X-ray diffraction under grazing incidence conditions can provide the required information. In this Primer, grazing incidence X-ray diffraction (GIXD) is comprehensively introduced, starting from basic considerations on X-ray diffraction at crystals with reduced dimensionality and the optical properties of X-rays, followed by a more in-depth description of an experimental performance, including X-ray sources, goniometers and detectors. Experimental errors, limitations and reproducibility are discussed. Various applications, from highly ordered inorganic single crystal surfaces to weakly ordered polymer thin films, are presented to illustrate the potential of GIXD. Data visualizations, representations and evaluation strategies are summarized, based on the example of anthracene thin films. The Primer compiles information relevant to perform high-quality GIXD experiments, evaluate data and interpret results, to extend knowledge about X-ray diffraction from surfaces, interfaces and thin films. Structures of surfaces and thin films can be investigated by performing X-ray diffraction under grazing incidence conditions. This Primer explores how grazing incidence X-ray diffraction is used to obtain crystallographic information, including in situ characterization, data collection, analysis and visualization, across a range of applications.