Pulsed magnetic field gradients are essential for MR imaging and localized spectroscopy applications. However, besides the desired linear field gradients, pulsed currents in a strong external magnetic field also generate unwanted effects like eddy currents, gradient coil vibrations and acoustic noise. While the temporal magnetic field perturbations associated with eddy currents lead to spectral line shape distortions and signal loss, the vibration-related modulations lead to anti-symmetrical sidebands of any large signal (i.e. water), thereby obliterating the signals from low-concentration metabolites. Here the measurement, characterization and compensation of vibration-related magnetic field perturbations is presented. Following a quantitative evaluation of the various temporal components of the main magnetic field, a digital B0 magnetic field waveform is generated which reduces all temporal variations of the main magnetic field to within the spectral noise level.