SGLT2 inhibitors are strongly recommended in guidelines to treat patients with heart failure with reduced ejection fraction, but their clinical benefits at higher ejection fractions are less well established. Two large-scale trials, DELIVER and EMPEROR-Preserved, in heart failure with mildly reduced or preserved ejection fraction have been done, providing power to examine therapeutic effects on cardiovascular mortality and in patient subgroups when combined with the earlier trials in reduced ejection fraction. We did a prespecified meta-analysis of DELIVER and EMPEROR-Preserved, and subsequently included trials that enrolled patients with reduced ejection fraction (DAPA-HF and EMPEROR-Reduced) and those admitted to hospital with worsening heart failure, irrespective of ejection fraction (SOLOIST-WHF). Using trial-level data with harmonised endpoint definitions, we did a fixed-effects meta-analysis to estimate the effect of SGLT2 inhibitors on various clinical endpoints in heart failure The primary endpoint for this meta-analysis was time from randomisation to the occurrence of the composite of cardiovascular death or hospitalisation for heart failure. We assessed heterogeneity in treatment effects for the primary endpoint across subgroups of interest. This study is registered with PROSPERO, CRD42022327527. Among 12 251 participants from DELIVER and EMPEROR-Preserved, SGLT2 inhibitors reduced composite cardiovascular death or first hospitalisation for heart failure (hazard ratio 0·80 [95% CI 0·73-0·87]) with consistent reductions in both components: cardiovascular death (0·88 [0·77-1·00]) and first hospitalisation for heart failure (0·74 [0·67-0·83]). In the broader context of the five trials of 21 947 participants, SGLT2 inhibitors reduced the risk of composite cardiovascular death or hospitalisation for heart failure (0·77 [0·72-0·82]), cardiovascular death (0·87 [0·79-0·95]), first hospitalisation for heart failure (0·72 [0·67-0·78]), and all-cause mortality (0·92 [0·86-0·99]). These treatment effects for each of the studied endpoints were consistently observed in both the trials of heart failure with mildly reduced or preserved ejection fraction and across all five trials. Treatment effects on the primary endpoint were generally consistent across the 14 subgroups examined, including ejection fraction. SGLT2 inhibitors reduced the risk of cardiovascular death and hospitalisations for heart failure in a broad range of patients with heart failure, supporting their role as a foundational therapy for heart failure, irrespective of ejection fraction or care setting. None.