To observe the effects of electroacupuncture (EA) on NLRP3 inflammasome and its downstream protein gastermin D (GSDMD) in rats with primary dysmenorrhea (PDM), and to explore the potential mechanism of EA on the treatment of PDM. Forty healthy female SD rats without pregnancy were randomly divided into a control group, a model group, an EA group and an ibuprofen group, 10 rats in each group. PDM model was prepared by injection of estradiol benzoate and oxytocin. Except the control group, the rats in each group were subcutaneously injected with estradiol benzoate for 10 days, and oxytocin was injected on the 11th day. The rats in the EA group were intervened with EA (dense wave, frequency of 50 Hz) at "Guanyuan" (CV 4) and "Sanyinjiao" (SP 6) at the same time of modeling, once a day, 20 min each time, for 10 consecutive days. The rats in the ibuprofen group were treated with 0.8 mL of ibuprofen by gavage (concentration of ibuprofen solution was 1.25 mg/mL) for 10 consecutive days. After modeling, the writhing reaction was observed. After intervention, the HE staining method was used to observe the histological morphology of uterus and evaluate the pathological damage score of uterus; ELISA method was used to detect the serum levels of prostaglandin E2 (PGE2) and prostaglandin F2α (PGF2α); Western blot method was used to detect the protein expression of NLRP3, apoptosis related spot like protein (ASC), caspase-1, GSDMD, GSDMD-N and inflammatory factors (interleukin [IL]-1β, IL-18) in uterine tissue. In the model group, a large number of vacuolar degeneration and death of endometrial epithelial cells, spiral arterioles congestion in lamina propria and neutrophil infiltration were observed. In the EA group, there was a small amount of vacuolar degeneration and death of endometrial epithelial cells, a small amount of spiral arterioles congestion in the lamina propria, and a small amount of neutrophils infiltration. In the ibuprofen group, there was very small number of degeneration and death of endometrial epithelial cells, and no obvious arterial congestion was found in lamina propria, and neutrophil infiltration was occasionally seen. Compared with the control group, in the model group the number of writhing was increased (P<0.01), the writhing reaction score and serum level of PGF2α and PGF2α/PGE2 value were increased (P<0.01), the level of PGE2 was decreased (P<0.01). Compared with the model group, in the EA group and the ibuprofen group the number of writhing were decreased (P<0.05), the latency of writhing was prolonged (P<0.01), the writhing reaction scores and serum levels of PGF2α and PGF2α/PGE2 values were decreased (P<0.05, P<0.01), the levels of PGE2 were increased (P<0.01). Compared with the control group, the protein expression of NLRP3, ASC, caspase-1, GSDMD, GSDMD-N, IL-1β and IL-18 in the uterine tissues of rats was increased in the model group (P<0.01). Compared with the model group, the protein expression of NLRP3, ASC, caspase-1, GSDMD, GSDMD-N, IL-1β and IL-18 in the uterine tissues of rats was decreased in the EA group and the ibuprofen group (P<0.01, P<0.05). There was no significant difference between the EA group and the ibuprofen group in the above indexes (P>0.05). EA could alleviate pain and uterine tissue injury in rats with PDM. The mechanism may be related to the inhibition of the activation of NLRP3 inflammasome in rat uterine tissues, thereby inhibiting pyroptosis and its inflammatory factors release.