Endometritis, an inflammatory response of the uterus tissue, is characterized by the production of inflammatory cytokines and migration of neutrophil (PMN) into the uterus tissue. Melatonin has been demonstrated to have anti-inflammatory and antioxidant effects. The purpose of this study was to investigate the protective effects of melatonin on lipopolysaccharide (LPS)-induced endometritis in mice. An endometritis model was induced by LPS and melatonin was given 1 h before LPS treatment. The results showed that melatonin inhibited LPS-induced pathologic changes, Myeloperoxidase (MPO) activity, and levels of interleukin-1 beta (IL-1β). Melatonin also inhibited LPS-induced thioredoxin-interacting protein (TXNIP)/NOD-like receptor family, pyrin domain containing 3 (NLRP3) inflammasome and nuclear factor kappa B (NF-κB) activation, reactive oxygen species (ROS) production, and endoplasmic reticulum (ER) stress. Furthermore, melatonin was found to increase AMPK activity. In conclusion, our results demonstrated that melatonin inhibited ER stress-associated TXNIP/NLRP3 inflammasome activation with a regulation of adenosine monophosphate activated protein kinase (AMPK) in LPS-induced endometritis. Melatonin may serve as a promising nutritional supplement for the treatment of endometritis.