Most NMR localization techniques use pulsed magnetic field gradients which, however, induce multiexponentially decaying eddy currents that distort images and spectra. This work describes a comprehensive strategy to measure and to exactly compensate for the induced gradient and the shift in B0 field which are produced and also to compensate for other terms like cross-talk or nonlinear terms. The time dependence of the gradient, and, if desired, of the B0 shift and other terms, is measured from FID signals with a method that distinguishes these components. The signals are obtained from a small sample successively at two or more positions by driving the gradient coil with a step function current pulse. A multiexponential fit through the measured temporal behavior of the gradient determines the amplitudes and time constants of the various exponential decay terms. A model allows calculation of the exact shape and parameters of the current pulse required to compensate for the eddy-current effects. This also turns out to be a multiexponential function, with, however, time constants differing from those of the eddy currents. They would only be the same if the shaping did not itself produce eddy currents. After compensation of the gradient component is achieved, the ΔB0(t) component is measured and similarly corrected, as can also be the other terms. The procedure is suited for automation and should avoid long and tedious adjustments by trial and error of the compensation, including that with shielded gradients. © 1990.