Studies of flux anomalies statistics and perturbations in stellar streams have the potential to constrain models of warm dark matter (WDM), including sterile neutrinos. Producing these constraints requires a parametrization of the WDM mass function relative to that of the cold dark matter (CDM) equivalent. We use five WDM models with half-mode masses, $M_mathrm{hm}=[1.3,35]times10^{8}$~$M_{odot}$, spread across simulations of the Local Group, lensing ellipticals and the $z=2$ universe, to generate such a parametrization: we fit parameters to a functional form for the WDM-to-CDM halo mass function ratio, $n_mathrm{WDM}(M_{X})/n_mathrm{CDM}(M_{X})$, of ($1+(alpha M_mathrm{hm}/M_{X})^{beta})^{gamma}$. For $M_{X}equiv$ virial mass of central halos we obtain $alpha=2.3$, $beta=0.8$, and $gamma=-1.0$, and this fit is steeper than the extended Press-Schechter formalism predicts. For $M_{X}equiv$ mass of subhalos we instead obtain $alpha=4.2$, $beta=2.5$ and $gamma=-0.2$; in both mass definitions the scatter is $sim20$~per~cent. The second fit typically underestimates the relative abundance of $z=2$ WDM subhaloes at the tens of per cent level. We caution that robust constraints will require bespoke simulations and a careful definition of halo mass, particularly for subhalos of mass $<10^{8}M_{odot}$.