There is a severe lack of effective treatments for ulcerative colitis (UC), a recurrent and intractable inflammatory bowel disease. The identification of valid targets and new drugs is an urgent need. In this study, we identified the XBP-1 agonist HLJ2 as a promising treatment candidate. In an in vivo mouse model of DSS-induced colitis, HLJ2 decreased weight loss, colon contracture, disease activity index (DAI), colon mucosa damage index (CMDI) and histopathological index (HI). HLJ2 also decreased myeloperoxidase (MPO) activity and reduced production of the inflammatory cytokines TNF-α, IL-1β, and IL-6. HLJ2 improved intestinal mucosa damage induced by dextran sodium sulfate (DSS) and increased the expression of ZO-1 and claudin-1. Fecal 16s rRNA high-throughput sequencing demonstrated a significant improvement in UC intestinal dysbacteriosis in mice treated with HLJ2, including increased abundance of probiotics such as Lachnospiraceae, Prevotellaceae, and Lactobacillaceae. At the same time there was a reduction in the abundance of pathogenic or conditional pathogenic microorganisms such as Bacteroidaceae, Porphyromonadaceae, Deferribacteraceae, and Pseudomonadaceae in HLJ2-treated mice compared with untreated mice. Our results demonstrated that the XBP1 agonist HLJ2 inhibits inflammation, regulates the intestinal flora, and protects the intestinal mucosa. It is thus a potential therapeutic agent for ulcerative colitis.