Mounting evidence indicates that myocardial fibrosis (MF) is frequently intertwined with immune and metabolic disorders. This comprehensive review aims to delve deeply into the crucial role of immune-related signature genes in the pathogenesis and progression of MF. This exploration holds significant importance as understanding the underlying mechanisms of MF is essential for developing effective diagnostic and therapeutic strategies. The dataset GSE9735 about myocardial fibrosis and non-fibrosis was downloaded from GEO database. Differentially expressed genes (DEGs) were identified by 'limma' package in R software. Then, the biological function of DEG was determined by gene ontology (GO) and Kyoto Encyclopedia of Genes and Genomes (KEGG) pathway enrichment analysis. XCell was used to estimate the composition pattern of matrix and immune cells. Protein-protein interaction (PPI) network was constructed based on STRING analysis software, and Hub genes were screened and functional modules were analyzed. The correlation between hub genes and immune cell subtypes was analyzed. Hub genes with |correlation coefficient|> 0.45 and p-value < 0.05 were used as characteristic biomarkers. Finally, the logistic regression model is used to verify the three markers in the training set and verification set (GSE97358 and GSE225336). A total of 635 DEGs were identified. Functional enrichment analysis shows that inflammation and immune response, extracellular matrix and structural remodeling play an important role in the pathological mechanism of MF. Immune cell infiltration analysis showed that immune cells (Plasma cells, Eosinophils, Chondrocytes and Th2 cells) significantly changed in MF pathological conditions. In PPI network analysis, IL1β, TTN, PTPRC, IGF1, ALDH1A1, CYP26A1, ALDH1A3, MYH11, CSF1R and CD80 were identified as hub genes, among which IL1β, CYP26A1 and GNG2 were regarded as immune-related characteristic markers. The AUC scores of the three biomarkers are all above 0.65, which proves that they have a good discrimination effect in MF. In this study, three immune-related genes were identified as diagnostic biomarkers of MF, which provided a new perspective for exploring the molecular mechanism of MF. This study takes a comprehensive approach to understanding the intricate relationship between myocardial fibrosis and immune metabolism. By identifying key immune-related biomarkers, this study not only reveals the molecular basis of myocardial fibrosis but also paves the way for the development of novel diagnostic tools and therapeutic strategies. These findings are critical for improving patient prognosis and may have broader implications for studying and treating other cardiovascular diseases associated with immune dysregulation.