Yttrium iron garnet is the ubiquitous magnetic insulator used for studying pure spin currents. The exchange constants reported in the literature vary considerably between different experiments and fitting procedures. Here we calculate them from first principles. The local Coulomb correction (U-J) of density-functional theory is chosen such that the parametrized spin model reproduces the experimental Curie temperature and a large electronic band gap, ensuring an insulating phase. The magnon spectrum calculated with our parameters agrees reasonably well with that measured by neutron scattering. A residual disagreement about the frequencies of optical modes indicates the limits of the present methodology.