Intracerebral hemorrhage (ICH) is one of the most common subtypes of stroke. This study aimed to investigate the mechanism of Astragaloside IV (AS-IV) on inflammatory injury after ICH. The ICH model was established by the injection of collagenase and treated with ASIV (20 mg/kg or 40 mg/kg). The neurological function, water content of the bilateral cerebral hemisphere and cerebellum, and pathological changes in brain tissue were assessed. The levels of interleukin-1 beta (IL-1β), IL-18, tumor necrosis factor-alpha, interferon-gamma, and IL-10 were detected by enzyme-linked immunosorbent assay. The levels of Kruppel-like factor 2 (KLF2), NOD-like receptor family pyrin domain containing 3 (NLRP3), GSDMD-N, and cleaved-caspase-1 were detected by reverse transcription-quantitative polymerase chain reaction and Western blot assay. The binding relationship between KLF2 and NLRP3 was verified by chromatin-immunoprecipitation and dual-luciferase assays. KLF2 inhibition or NLRP3 overexpression was achieved in mice to observe pathological changes. The decreased neurological function, increased water content, severe pathological damage, and inflammatory response were observed in mice after ICH, with increased levels of NLRP3/GSDMD-N/cleaved-caspase-1/IL-1β/IL-18 and poorly-expressed KLF2 in brain tissue. After AS-IV treatment, the neurological dysfunction, high brain water content, inflammatory response, and pyroptosis were alleviated, while KLF2 expression was increased. KLF2 bonded to the NLRP3 promoter region and inhibited its transcription. Down-regulation of KLF2 or upregulation of NLRP3 reversed the effect of AS-IV on inhibiting pyroptosis and reducing inflammatory injury in mice after ICH. AS-IV inhibited NLRP3-mediated pyroptosis by promoting KLF2 expression and alleviated inflammatory injury in mice after ICH.