Specifying photon spectra of clinical linacs using a functional form is useful for many applications, including virtual source modelling and spectral unfolding from dosimetric measurements such as transmission data or depth-dose curves. In this study, 11 functional forms from the literature are compiled and quantitatively compared. A new function is proposed which offers improvements over existing ones. The proposed function is simple, physics-based and has four free parameters, one of which is the mean incident electron kinetic energy. A comprehensive benchmark set of validated, high-precision Monte Carlo spectra is generated and used to evaluate the strengths and limitations of different functions. The benchmark set has 65 spectra (3.5-30 MV) from Varian, Elekta, Siemens, Tomotherapy, Cyberknife and research linacs. The set includes spectra on- and off-axis from linacs with and without a flattening filter, and in treatment and imaging modes. The proposed function gives the lowest spectral deviations among all functions. It reproduces the energy fluence values in each bin for the benchmark set with a normalized root-mean-square deviation of 1.7%. The mean incident electron kinetic energy, maximum photon energy, most-probable energy and average energy are reproduced, on average, within 1.4%, 4.3%, 3.9% and 0.6% of their true values, respectively. The proposed function is well behaved when used for spectral unfolding from dosimetric data. The contribution of the 511 keV annihilation peak and the energy spread of the incident electron beam can be added as additional free parameters.