Diabetes mellitus (DM) patients are at a higher risk of developing brain injury characterized by neuronal death. Melatonin, a hormone produced by the pineal gland, exerts neuroprotective effects against brain damage. However, the effect of melatonin on diabetes‐induced brain injury has not been elucidated. This study was to evaluate the role of melatonin against neuronal death in DM and to elucidate the underlying mechanisms. Herein, we found that melatonin administration significantly alleviated the neuronal death in both streptozotocin (STZ)‐induced diabetic mice and high glucose (HG)‐treated neuronal cells. Melatonin inhibited neuronal pyroptosis and excessive autophagy, as evidenced by decreased levels of NLRP3, cleaved caspase‐1, GSDMD‐N, IL‐1β, LC3, Beclin1, and ATG12 both in vivo and in vitro. MicroRNA‐214‐3p (miR‐214‐3p) was decreased in DM mice and HG‐treated cells, and such a downregulation was corrected by melatonin, which was accompanied by repression of caspase‐1 and ATG12. Furthermore, downregulation of miR‐214‐3p abrogated the anti‐pyroptotic and anti‐autophagic actions of melatonin in vitro. Our results indicate that melatonin exhibits a neuroprotective effect by inhibiting neuronal pyroptosis and excessive autophagy through modulating the miR‐214‐3p/caspase‐1 and miR‐214‐3p/ATG12 axes, respectively, and it might be a potential agent for the treatment of brain damage in the setting of DM.