The therapeutic effect of most traditional Chinese medicines (TCM) on ulcerative colitis is unclear, The objective of this study was to develop a core herbal screening model aimed at facilitating the transition from active ulcerative colitis (UC) to inactive. We obtained the gene expression dataset GSE75214 for UC from the GEO database and analysed the differentially expressed genes (DEGs) between active and inactive groups. Gene modules associated with the active group were screened using WGCNA, and immune-related genes (IRGs) were obtained from the ImmPort database. The TCMSP database was utilized to acquire the herb-molecule-target network and identify the herb-related targets (HRT). We performed intersection operations on HRTs, DEGs, IRGs, and module genes to identify candidate genes and conducted enrichment analyses. Subsequently, three machine learning algorithms (SVM-REF analysis, Random Forest analysis, and LASSO regression analysis) were employed to refine the hubgene from the candidate genes. Based on the hub genes identified in this study, we conducted compound and herb matching and further screened herbs related to abdominal pain and blood in stool using the Symmap database.Besides, the stability between molecules and targets were assessed using molecular docking and molecular dynamic simulation methods. An intersection operation was performed on HRT, DEGs, IRGs, and module genes, leading to the identification of 23 candidate genes. Utilizing three algorithms (RandomForest, SVM-REF, and LASSO) for analyzing the candidate genes and identifying the intersection, we identified five core targets (CXCL2, DUOX2, LYZ, MMP9, and AGT) and 243 associated herbs. Hedysarum Multijugum Maxim. (Huangqi), Sophorae Flavescentis Radix (Kushen), Cotyledon Fimbriata Turcz. (Wasong), and Granati Pericarpium (Shiliupi) were found to be capable of relieving abdominal pain and hematochezia during active UC. Molecular docking demonstrated that the compounds of the four aforementioned herbs showed positive docking activity with their core targets. The results of molecular dynamic simulations indicated that well-docked active molecules had a more stable structure when bound to their target complexes. The study has shed light on the potential of TCMs in treating active UC from an immunomodulatory perspective, consequently, 5 core targets and 4 key herbs has been identified. These findings can provide a theoretical basis for subsequent management and treatment of active UC with TCM, as well as offer original ideas for further research and development of innovative drugs for alleviating UC.