BACKGROUND: Daifu Decoction (DFD), a patented herbal prescription used to prevent and treat ulcerative colitis (UC). This study aimed to reveal the effect of DFD on the relapse of UC and its mechanism via integrated retrospective clinical analysis, network pharmacology and in vivo and in vitro experimental validation. METHODS: First, the clinical data of UC patients treated with DFD were reviewed from a real-world study (RWS), and the relapse at 24 weeks after drug withdrawal was recorded to evaluate the relapse rate. Next, the chemical components of DFD were identified via ultra performance liquid chromatography‒mass spectrometry (UPLC‒MS), and the differentially expressed genes (DEGs) between UC patients in the active and remission stages were screened as disease targets related to the relapse of UC from the Gene Expression Omnibus (GEO) database. The core components, targets and key signalling pathways of DFD for preventing the relapse of UC were discussed via network pharmacology. Finally, the above results were verified via molecular docking and in vivo and in vitro experiments. RESULTS: A total of 475 UC patients were included, and the relapse rate of UC treated with DFD was 23.9%. Additionally, the 221 components identified by UPLC-MS and 398 DEGs related to the relapse of UC enriched the main pathway of the relapse of UC was IL-17 signaling pathway and the inflammatory-related targets, such as IL6, PTGS2, MMP7, MMP3, MMP1. Moreover, molecular docking revealed that the core components of DFD were able to bind to inflammation-related targets, and in vivo and in vitro experiments demonstrated that DFD could inhibit the IL-17 pathway, increase the level of claudin-1, and control inflammation to prevent UC relapse. CONCLUSION: DFD can effectively prevent the relapse of UC which may be related to inhibiting the activation of IL-17 signalling pathway.