Background: Neuroprotective effects of ketogenic diets (KD) have been reported in stroke models, and nucleotide-binding domain (NOD)-like receptor protein 3 (NLRP3) inflammasome has also been implicated in the pathogenesis of stroke. This study aimed to investigate the effects of KD on NLRP3 inflammasome and explore the potential molecular mechanisms. Methods: In in vivo study, mice were fed with KD for 3 weeks and then subjected to middle cerebral artery occlusion/reperfusion (MCAO/R)-injury. In in vitro study, SH-SY-5Y cells were treated with ?-hydroxybutyrate (BHB) followed by oxygen?glucose deprivation/reoxygenation (OGD/R). NLRP3 inflammasome activation and related regulatory mechanisms were evaluated. Results: Mice fed with KD had increased tolerance to MCAO/R. KD inhibited endoplasmic reticulum (ER) stress and suppressed TXNIP/NLRP3 inflammasome activation in the brain. The in vitro study showed BHB (10 mM) prevented the mitochondrial translocation of dynamin-related protein 1 (Drp1) to inhibit mitochondrial fission. Furthermore, BHB decreased reactive oxygen species (ROS) generation, inhibited ROS-NLRP3 pathway in OGD/R-treated cells, and suppressed ER stress-induced NLRP3 inflammasome activation. Conclusions: KD may suppress ER stress and protect mitochondrial integrity by suppressing the mitochondrial translocation of Drp1 to inhibit NLRP3 inflammasome activation, thus exerting neuroprotective effects. Our findings provide evidence for the potential application of KD in the prevention of ischemic stroke.