Ziziphi Spinosae Semen (ZSS), a homology of medicine and a type of seed, has been widely used to improve sleep quality. The present study aimed to assess the effects of ZSS flavonoid (ZSSF) extracted and isolated from ZSS on gut microbiota and hypothalamus metabolomic profiles in a chronic restraint stress (CRS)-induced anxiety mouse model. ZSSF was prepared using microporous resin chromatography, and seven compounds were determined by UPLC-MS. ZSSF treatment dramatically reduced anxiety-like behaviors, exerted sedative-hypnotic effects, increased hippocampal 5-HT and 5-HTP, and enhanced intestinal barrier function through inhibiting colon ZO-1, Claudin-1, and Occludin expression and reducing TNF-α, IL-6, and IL-1β levels. Compared with the CRS group, the diversity of gut microbiota in ZSSF-group mice was increased, with an increase in