Context. Mg viii emission lines are observed in a range of astronomical objects such as the Sun, other cool stars and in the coronal line region of Seyfert galaxies. Under coronal conditions Mg viii emits strongly in the extreme ultraviolet (EUV) and soft X-ray spectral regions which makes it an ideal ion for plasma diagnostics. Aims. Two theoretical atomic models, consisting of 125 fine structure levels, are developed for the Mg viii ion. The 125 levels arise from the 2s 2 2p, 2s2p 2 , 2p 3 , 2s 2 3s, 2s 2 3p, 2s 2 3d, 2s2p3s, 2s2p3p, 2s2p3d, 2p 2 3s, 2p 2 3p and 2p 2 3d configurations. Electron impact excitation collision strengths and radiative transition probabilities are calculated for both Mg viii models, compared with existing data, and the best model selected to generate a set of theoretical emission line intensities. The EUV lines, covering 312‐790 A, are compared with existing solar spectra (SERTS‐89 and SUMER), while the soft X-ray transitions (69‐97 A) are examined for potential density diagnostic line ratios and also compared with the limited available solar and stellar observational data. Methods. The R-matrix codes Breit-Pauli RMATRXI and RMATRXII are utilised, along with the PSTGF code, to calculate the collision strengths for two Mg viii models. Collision strengths are averaged over a Maxwellian distribution to produce the corresponding e ective collision strengths for use in astrophysical applications. Transition probabilities are also calculated using the CIV3 atomic structure code. The best data are then incorporated into the modelling code CLOUDY and line intensities generated for a range of electron temperatures and densities appropriate to solar and stellar coronal plasmas. Results. The present e ective collision strengths are compared with two previous calculations. Good levels of agreement are found with the most recent, but there are large di erences with the other for forbidden transitions. The resulting line intensities compare favourably with the observed values from the SERTS-89 and SUMER spectra. Theoretical soft X-ray emission lines are presented and several density diagnostic line ratios examined, which are in reasonable agreement with the limited observational data available.