BACKGROUNDThyroid cancer (TC) is the most prevalent endocrine malignancy, with a rising incidence necessitating safer treatment strategies to reduce overtreatment and its side effects. Xiaoyao Powder (XYP), a widely used herbal formula, shows promise in treating TC. This study aims to investigate the mechanisms by which XYP may affect TC.METHODSThe components of XYP were identified through database retrieval, and targets related to TC were collected to construct a target network for key screening. GEO dataset samples analyzed immune cells and identified significantly differentially expressed core genes (SDECGs). Based on SDECG expression and clustering, samples were classified for comparison. WGCNA was employed to identify gene modules linked to clinical characteristics. ML models screened characteristic genes and constructed a nomogram validated using another GEO dataset. MR methods explored causal relationships between genes and TC.RESULTSThe top ten active components of XYP were identified, along with 27 SDECGs that exhibited significant differences in immune cell infiltration between TC patients and normal controls. The nomogram effectively predicted TC risk, validated through ROC curves. Key characteristic genes included SMIM1, PPP1R16A, KIAA1462, DNAJC22, and EFNA5.CONCLUSIONXYP may treat TC by regulating SMIM1, PPP1R16A, KIAA1462, DNAJC22, EFNA5, and associated immune pathways; this provides theoretical support for its potential mechanisms.