High-pressure crystallographic data can be measured using a diamond anvil cell (DAC), which allows the sample to be viewed only along a cell vector which runs perpendicular to the diamond anvils. Although centring a sample perpendicular to this direction is straightforward, methods for centring along this direction often rely on sample focusing, measurements of the direct beam or short data collections followed by refinement of the crystal offsets. These methods may be inaccurate, difficult to apply or slow. Described here is a method based on precise measurement of the offset in this direction using a confocal optical device, whereby the cell centre is located at the mid-point of two measurements of the distance between a light source and the external faces of the diamond anvils viewed along the forward and reverse directions of the cell vector. It is shown that the method enables a DAC to be centred to within a few micrometres reproducibly and quickly.