For the identification of potential biomarkers for ulcerative colitis (UC) and prediction of their targeted traditional Chinese medicines, datasets containing human UC and healthy control tissues (GSE179285, GSE206285, and GSE87466) were downloaded from the GEO database. The GSE179285 and GSE206285 datasets were merged, and the differentially expressed genes (DEGs) between UC and healthy control tissues were screened using the limma R package. The LASSO regression model and SVM-RFE (support vector machine recursive feature elimination) algorithm were used to identify core biomarkers. The GSE87466 dataset was used as a validation cohort, and the ROC (receiver operating characteristic) curve was used to evaluate the diagnostic performance. CIBERSORT was used to investigate the immune infiltration characteristics in UC, and the correlation between potential biomarkers and different immune cells was further analyzed. Subsequently, the targeted traditional Chinese medicinal herbs were predicted using the HERB database. In total, 157 DEGs were screened out, with 102 genes upregulated and 55 genes downregulated. Functional enrichment analysis showed that these DEGs were mainly involved in IL-17 and TNF signaling pathway, rheumatoid arthritis, chemokine signaling pathway, humoral immune response, neutrophil chemotaxis, neutrophil migration, etc. LOC389023, OLFM4, AQP8, and CWH43 were identified as potential biomarkers for UC, and their diagnostic values were significant in the GSE87466 validation dataset. CIBERSORT immune infiltrate analysis showed significant differences in immune infiltration characteristics between UC and healthy control tissues. High levels of CD4+ memory activated T cells, M1 macrophages, and neutrophils were found in the UC group, while high levels of memory B cells, CD4+ memory resting T cells, M2 macrophages, and resting dendritic cells were found in the healthy control group. Seven traditional Chinese medicinal herbs targeting core biomarkers, including Sojae Semen Praeparatum, Fructus Viticis Cannabifoliae, Herba Equiseti Palustris, Liquor, Sophora alopecuroides L., Cervi Cornu Pantotrichum, and Placenta Hominis, were predicted in the HERB database. The study suggested that LOC389023, OLFM4, AQP8, and CWH43 were identified as diagnostic biomarkers for UC, and the aforementioned seven targeted traditional Chinese medicinal herbs may play a therapeutic role in UC by regulating gut microbiota, affecting inflammation pathways, and modulating the immune system.