Acute lung injury (ALI)/ acute respiratory distress syndrome (ARDS) is featured by intensive inflammatory responses and oxidative stress, which lead to cytokine storms and pyroptosis. Here, we aimed to investigate whether melatonin was capable of alleviating LPS-induced ALI via activating the nuclear factor erythroid 2-related factor 2/heme oxygenase 1 (Nrf2/HO-1) signaling axis and inhibiting pyroptosis. Mice were injected with melatonin (30 mg/kg) intraperitoneally for consecutive five days before LPS instillation intratracheally, and human alveolar epithelial cell (AECⅡ) A549 cell lines and murine macrophages Raw264.7 cell lines were pretreated with melatonin (400 μM) before LPS (10 μg/ml) stimulation. The result demonstrated that LPS induced obvious lung injury characterized by alveolar damage, neutrophil infiltration and lung edema as well as the reduction of the survival rate of mice, which were totally reversed by melatonin pretreatment. Mechanistically, melatonin pretreatment activated nuclear factor erythroid2-related factor (Nrf) 2 signaling, subsequently, drove antioxidant pathways including significant increases in the expression of Nrf2, HO-1, NQO1, Mn-SOD and Catalase in vivo and in vitro. Simultaneously, melatonin inhibited ROS and MDA overproduction, iNOS expression as well as TNF-α and IL-1β expression and release. Furthermore, melatonin inhibited LPS-induced pyroptosis by reversing the overexpression of NLRP3, Caspase-1, IL-1β, IL-18 and GSDMD-N, as well as LDH release and TUNEL-positive cells in A549 cells and Raw264.7 cells. Overall, the current study suggests that melatonin exerts protective roles on LPS-induced ALI and pyroptosis by inhibiting NLRP3-GSDMD pathway via activating Nrf2/HO-1 signaling axis.