Mass spectrometers operate by ionizing chemical compounds to generate charged molecules or molecule fragments. These ions are then sorted and detected according to their mass-to-charge ratios. The process typically involves three main steps: ionization, mass analysis, and detection.