Context. Galactic archaeology, the study of the formation and evolution of the Milky Way by reconstructing its past from its current constituents, requires precise and accurate knowledge of stellar parameters for as many stars as possible. To achieve this, a number of large spectroscopic surveys have been undertaken and are still ongoing. Aims. So far consortia carrying out the different spectroscopic surveys have used different tools to determine stellar parameters of stars from their derived effective temperatures (T eff ), surface gravities (log g), and metallicities ([Fe/H]); the parameters can be combined with photometric, astrometric, interferometric, or asteroseismic information. Here we aim to homogenise the stellar characterisation by applying a unified tool to a large set of publicly available spectrophotometric data. Methods. We used spectroscopic data from a variety of large surveys combined with infrared photometry from 2MASS and AllWISE and compared these in a Bayesian manner with PARSEC isochrones to derive probability density functions (PDFs) for stellar masses, ages, and distances. We treated PDFs of pre-helium-core burning, helium-core burning, and post helium-core burning solutions as well as different peaks in multimodal PDFs (i.e. each unimodal sub-PDF) of the different evolutionary phases separately. Results. For over 2.5 million stars we report mass, age, and distance estimates for each evolutionary phase and unimodal sub-PDF. We report Gaussian, skewed, Gaussian, truncated Gaussian, modified truncated exponential distribution or truncated Student's t-distribution functions to represent each sub-PDF, allowing us to reconstruct detailed PDFs. Comparisons with stellar parameter estimates from the literature show good agreement within uncertainties. Conclusions. We present UniDAM, the unified tool applicable to spectrophotometric data of different surveys, to obtain a homogenised set of stellar parameters.