Objective To analyze the core differential genes,enrichment process,and immune infiltration of alopecia areata(AA),and to predict the effective traditional Chinese herb for the treatment of AA.Methods GSE68801 dataset was downloaded,and differential genes were screened by expression difference and module analysis.Differential genes were enriched by CTD and PPI network was constructed by STRING platform.Core genes in the PPI network were screened by Cytoscape and their diagnostic efficacy was predicted by ROC curves.The GSE45512 dataset was used to validate.CIBERSORT was used to analyze the infiltration of immune cells in AA tissues,and the core genes related to immune infiltration were screened by Spearman.Effective traditional Chinese herbs were predicted by core memedical database.Results A total of 255 differentially expressed genes were identified,which were mainly involved in hair cycle,cytokine-cytokine receptor interaction,chemokine signaling pathway,and Th1 and Th2 cell differentiation.The core genes of PPI were BMP2,CCL5,CXCL10,CXCL9,IL10RA,CD2,CD3D,CD8A,ITGAL.The infiltration of T cells gamma delta,Macrophages M1 and Macrophages M2 increased significantly,while Mast cells resting decreased.The related core genes were BMP2,CD8A,CXCL10,IL10RA,ITGAL.The predicted effective Chinese herbs included wolfberry,Chinese angelica,salvia miltiorrhiza,ginseng,safflower,and licorice.Conclusion The core genes related to the immune infiltration of AA are obtained by bioinformatics methods,and the effective Chinese herbal medicines are predicted,which can provide theoretical basis for further exploring the pathogenesis and targeted therapy of AA.