Objectives] To analyze the main chemical components of traditional Chinese medicine (TCM) Poria cocos by liquid chromatography-mass spectrometry, and explore the active components for P. cocos in the treatment of primary dysmenorrhea (PD) by network pharmacology to predict its quality markers (Q-marker). [Methods] Ultra performance liquid chromatography-quadrupole tandem time-of-flight mass spectrometry (UPLC-Q-TOF-MS) in positive and negative ion mode was used to collect high quality MS and MS/MS data of Poria cocos, and qualitative characterization of the components in Poria cocos was performed using Analyst TF 1.7.1 and PeakView 2.2 software with reference to internal databases and literature. Taking the above identified chemical components as the research object, we used network pharmacology to discover the potential effective components and their key targets of PD, and metabolic pathway enrichment analysis of the core targets was performed to screen the Q-marker of P. cocos based on the five principles of Q-marker of TCM. [Results] UPLC-Q-TOF-MS technique was used to identify 41 chemical components of P. cocos, including 3 amino acids, 26 triteipenoids, 4 lactones, 7 organic acids and 1 adenosine. It was more likely to lose H20 and C02 during cleavage and break at the carbonyl group. The triterpenoids were mainly in the form of [M-H] -peaks in negative ion mode, which was easy to lose some structural fragments such as H20, CH3COOH, CH4, C02, etc. Further network pharmacological analysis showed that 302 targets of chemical components of P. cocos, 518 targets of PD, 28 common targets of component and disease, and 27 core targets such as PTGS2, ESRI, TNF, IL1B were observed by PPI interactions network analysis. 451 biological processes such as hormone response and inflammatory response regulation were obtained by GO enrichment analysis. KEGG enrichment analysis showed that 89 pathways including PI3K/Akt signaling pathway, IL-17 signaling pathway and TNF signaling pathway were obtained. The connectivity value of components was analyzed. The core components with the connectivity value greater than 10, including poricoic acid A, polyporenic acid, polyporenic acid C, and 25-hydroxy-3-epidehydrotumoric acid were selected, while the key targets with the connectivity value greater than 15 ineluded TNF, PTGS2, IL1B and CASP3. Molecular docking between core components and key targets was performed, and most of the docking energy was less than -5 kcal/mol, indicating that the binding between the active components and target proteins of P. cocos was relatively stable, so 23 active components of P. cocos were determined. Following the five principles of Q-marker, four possible Q-markers of P. cocos were predicted, including poricoic acid A, pachymic acid, polyporenic acid C, and 25-hydroxy-3-epidehydrotumoric acid. [Conclusions] P. cocos was mainly composed of triterpenoids, its effect on the treatment of PD may be achieved mainly by poricoic acid A, pachymic acid, polyporenic acid C, and 25-hydroxy-3-epi-dehydrotumoric acid acting on PTGS2, ESRI, TNF, IL1B and other targets to regulate PI3K/Akt signaling pathway, IL-17 signaling pathway, TNF signaling pathway, etc. Based on these active components, poricoic acid A, pachymic acid, polyporenic acid C, and 25-hydroxy-3-epi-dehydrotumoric acid could be taken as Q-markers of P. cocos, which provided a solid basis for further improving the quality standard of P. cocos. [ABSTRACT FROM AUTHOR]