Context. Gas cooling processes in the interstellar medium (ISM) are key to understanding how star formation occurs in galaxies. Far-infrared (FIR) fine-structure emission lines can be used to infer gas conditions and trace different phases of the ISM. Aims. We model eight of the most important FIR emission lines and explore their variation with star formation rate (SFR) out to z = 6 using cosmological hydrodynamical simulations. In addition, we study how different physical parameters, such as the interstellar radiation field (ISRF) and metallicity, impact the FIR lines and line ratios. Methods. We implemented a physically motivated multi-phase model of the ISM by post-processing the EAGLE cosmological simulation and using CLOUDY look-up tables for line emissivities. In this model we included four phases of the ISM: dense molecular gas, neutral atomic gas, diffuse ionised gas (DIG), and H II regions. Results. Our model shows reasonable agreement (to ∼0.5 dex) with the observed line luminosity–SFR relations up to z = 6 in the FIR lines analysed. For ease of comparison, we also provide linear fits to our model results. Our predictions also agree reasonably well with observations in diagnostic diagrams involving various FIR line ratios. Conclusions. We find that [C II] is the best SFR tracer of the FIR lines even though it arises from multiple ISM phases, while [O III] and [N II] can be used to understand the DIG–H II balance in the ionised gas. In addition, line ratios such as [C II]/[O III] and [N II]/[O I] are useful for deriving parameters such as ISRF, metallicity, and specific SFR. These results can help interpret the observations of the FIR lines from the local Universe to high redshifts.