Heart failure (HF) is the final stage of heart disease. An increasing number of experiments and clinical reports have shown that traditional Chinese medicine (TCM) has many therapeutic effects and advantages in treating HF. In this study, we used bioinformatics methods to screen key genes and predict the components of Chinese herbal medicines with preventive and therapeutic effects on HF. GSE120895 and GSE21610 HF chips were downloaded from the Gene Expression Omnibus database. We screened differentially expressed genes (DEGs). Weighted gene coexpression network analysis was performed to determine key modules. Genes in key modules were used for Gene Ontology and Kyoto Encyclopedia of Genes Genomes analysis to determine the biological functions. Finally, receiver operating characteristic curve analysis was used to screen out key genes, and single-sample GSEA was conducted to screen TCM compounds and effective ingredients of TCM compounds related to HF. We have selected a key module (MeTerquoise) and identified 489 DEGs, of which 357 are up regulated and 132 are down regulated. Gene Ontology and Kyoto Encyclopedia of Genes Genomes analyses indicated that the DEGs were associated with the extracellular matrix, fat metabolism and inflammatory response. We identified IL2, CXCR4, CCL5, THY1, CCN2, and IL7R as key genes. Single-sample GSEA showed that key genes were mainly related to energy metabolism, mitochondrial oxidative phosphorylation, extracellular matrix, and immunity. Finally, a total of 70 TCM compounds and 30 active ingredients of TCM compounds were identified. Bioinformatics methods were applied to preliminarily predict the key genes and TCM compounds involved in HF. These results provide theoretical support for the treatment of HF with TCM compounds and provide targets and research strategies for the development of related new Chinese medicines.