Primordial magnetic fields that exist before the photon-baryondecoupling epoch are damped on length scales below the photon diffusionand free-streaming scales. The energy injected into the plasma bydissipation of magnetosonic and Alfv'en waves heats photons, creating ay-type distortion of the black-body spectrum of the cosmic microwavebackground. This y-type distortion is converted into a μ-typedistortion when elastic Compton scattering is efficient. Therefore, wecan use observational limits on y- and μ-type distortions toconstrain properties of magnetic fields in the early universe. Assuminga Gaussian, random, and non-helical field, we calculate μ and y asa function of the present-day strength of the field, B0, smoothedover a certain Gaussian width, kc−1, as well as of the spectralindex of the power spectrum of fields, nB, defined by PB(k)∝knB. For a nearly scale-invariant spectrum with nB = −2.9 and aGaussian smoothing width of kc−1 = 1Mpc, the existingCOBE/FIRAS limit on μ yields B0 < 40 nG, whereas the projectedPIXIE limit on μ would yield B0 < 0.8 nG. For non-scale-invariantspectra, constraints can be stronger. For example, for B0 = 1 nG withkc−1 = 1Mpc, the COBE/FIRAS limit on μ excludes a widerange of spectral indices given by nB > −2.6. After decoupling, energydissipation is due to ambipolar diffusion and decaying MHD turbulence,creating a y-type distortion. The distortion is completely dominatedby decaying MHD turbulence, and is of order y ≈ 10−7 for a few nGfield smoothed over the damping scale at the decoupling epoch,kd, dec ≈ 290(B0/1nG)−1Mpc−1. The projected PIXIE limit on y wouldexclude B0 > 1.0 and 0.6 nG for nB = −2.9 and -2.3, respectively,and B0 > 0.6 nG for nB ⩾ 2. Finally, we find that the current limits on the optical depth to Thomsonscattering restrict the predicted y-type distortion to be y≲10−8.