Abstract We study the luminosity line ratio in a sample of nearby (z < 0.05) galaxies: 25 star-forming galaxies (SFGs) from the xCOLD GASS survey, 36 hard X-ray-selected active galactic nucleus (AGN) host galaxies from the BAT AGN Spectroscopic Survey, and 37 infrared-luminous galaxies from the SCUBA Local Universe Galaxy Survey. We find a trend for r 31 to increase with star formation efficiency (SFE). We model r 31 using the UCL-PDR code and find that the gas density is the main parameter responsible for the variation of r 31, while the interstellar radiation field and cosmic-ray ionization rate play only a minor role. We interpret these results to indicate a relation between SFE and gas density. We do not find a difference in the r 31 value of SFGs and AGN host galaxies, when the galaxies are matched in SSFR (〈r 31〉 = 0.52 ± 0.04 for SFGs and 〈r 31〉 = 0.53 ± 0.06 for AGN hosts). According to the results of the UCL-PDR models, the X-rays can contribute to the enhancement of the CO line ratio, but only for strong X-ray fluxes and for high gas density (n H > 104 cm−3). We find a mild tightening of the Kennicutt–Schmidt relation when we use the molecular gas mass surface density traced by CO(3–2) (Pearson correlation coefficient R = 0.83), instead of the molecular gas mass surface density traced by CO(1–0) (R = 0.78), but the increase in correlation is not statistically significant (p-value = 0.06). This suggests that the CO(3–2) line can be reliably used to study the relation between SFR and molecular gas for normal SFGs at high redshift and to compare it with studies of low-redshift galaxies, as is common practice.