Abstract Modelling complex line emission in the interstellar medium (ISM) is a degenerate, high-dimensional problem. Here, we present McFine, a tool for automated multi-component fitting of emission lines with complex hyperfine structure, in a fully automated way. We use Markov chain Monte Carlo (MCMC) to efficiently explore the complex parameter space, allowing for characterising model denegeracies. This tool allows for both local thermodynamic equilibrium (LTE) and radiative-transfer (RT) models. McFine can fit individual spectra and data cubes, and for cubes encourage spatial coherence between neighbouring pixels. It is also built to fit the minimum number of distinct components, to avoid overfitting. We have carried out tests on synthetic spectra, where in around 90 per cent of cases it fits the correct number of components, otherwise slightly fewer components. Typically, Tex is overestimated and τ underestimated, but accurate within the estimated uncertainties. The velocity and line widths are recovered with extremely high accuracy, however. We verify McFine by applying to a large Atacama Large Millimeter/submillimeter Array (ALMA) N2H+ mosaic of an high-mass star forming region, G316.75-00.00. We find a similar quality of fit to our synthetic tests, aside from in the active regions forming O-stars, where the assumptions of Gaussian line profiles or LTE may break down. To show the general applicability of this code, we fit CO(J = 2-1) observations of NGC 3627, a nearby star-forming galaxy, again obtaining excellent fit quality. McFine provides a fully automated way to analyse rich datasets from interferometric observations, is open source, and pip-installable.