ObjectiveThis study aims to identify m6A methylation-related and immune cell-related key genes with diagnostic potential for heart failure (HF) by leveraging various bioinformatics techniques.MethodsThe GSE116250 and GSE141910 datasets were sourced from the Gene Expression Omnibus (GEO) database. Correlation analysis was conducted between differentially expressed genes (DEGs) in HF and control groups, alongside differential m6A regulatory factors, to identify m6A-related DEGs (m6A-DEGs). Subsequently, candidate genes were narrowed down by intersecting key module genes derived from weighted gene co-expression network analysis (WGCNA) with m6A-DEGs. Key genes were then identified through the Least Absolute Shrinkage and Selection Operator (LASSO) analysis. Correlation analyses between key genes and differentially expressed immune cells were performed, followed by the validation of key gene expression levels in public datasets. To ensure clinical applicability, five pairs of blood samples were collected for quantitative real-time fluorescence PCR (qRT-PCR) validation.ResultsA total of 93 m6A-DEGs were identified (|COR| > 0.6, P < 0.05), and five key genes (LACTB2, NAMPT, SCAMP5, HBA1, and PRKAR2A) were selected for further analysis. Correlation analysis revealed that differential immune cells were negatively associated with the expression of LACTB2, NAMPT, and PRKAR2A (P < 0.05), while positively correlated with SCAMP5 and HBA1 (P < 0.05). Subsequent expression validation confirmed significant differences in key gene expression between the HF and control groups, with consistent expression trends observed across both training and validation sets. The expression trends of LACTB2, PRKAR2A, and HBA1 in blood samples from the qRT-PCR assay aligned with the results derived from public databases.ConclusionThis study successfully identified five m6A methylation-related key genes with diagnostic significance, providing a theoretical foundation for further exploration of m6A methylation’s molecular mechanisms in HF.