The study aimed to investigate the potential mechanism of the Xiaoyao pills (XYP) for treating insomnia using network pharmacology. The researchers employed several analytical methods and databases to predict and screen the active components and targets of XYP, as well as potential targets related to insomnia. Comparative analysis was then conducted to identify overlapping genes between the active component targets and insomnia-related targets. The researchers constructed networks of the active component-target and target pathways using Cytoscape software and the STRING database. Additionally, Gene Ontology (GO) and Kyoto Encyclopedia of Genes and Genomes (KEGG) enrichment analyses were performed using the DAVID database. The findings revealed 161 active components present in XYP and identified 76 potential targets associated with these active components. Furthermore, 36 overlapping genes were identified as both active component targets and targets related to insomnia treatment. The network pharmacology analysis highlighted the potential significance of radix bupleuri, Chinese angelica, and liquorice in the treatment of insomnia. The proposed mechanism of XYP in treating insomnia involved 10 core targets: TNF, IL1B, CASP3, TP53, HSP90AA1, PPARG, SLC6A4, ESR1, GSK3B, and AChE. The treatment of insomnia using XYP was found to primarily affect seven enriched GO terms and six related pathways. Notably, XYP targeted TNF, IL1B, CASP3, TP53, HSP90AA1, PPARG, SLC6A4, ESR1, GSK3B, and AChE, while participating in pathways such as neuroactive ligand-receptor interaction, pathways in cancer, and calcium signaling pathway. These findings provided valuable insights into the potential molecular targets and pathways through which XYP might exert its therapeutic effects in treating insomnia.