Vitamin B (nicotinamide (NAM)), one of the most important nutritional components for humans, exerts anti-inflammatory activity. This study was aimed at investigating the effect of NAM on the gut microbiota and short-chain fatty acids (SCFAs) in mice with chronic colitis. Colitis was induced in C57BL/6 male mice by administration of 1.5% dextran sulfate sodium (DSS), and the mice were intraperitoneally injected with normal saline (NS) or NAM. NAM treatment ameliorated weight loss and changes in colon length, disease activity index (DAI) score, and histologic scores. Moreover, enzyme-linked immunosorbent assay (ELISA) analysis of LPL cells revealed that the level of interleukin- (IL-) 6, IL-12p70, IL-1 β, tumor necrosis factor- (TNF-) α, interferon- (IFN-) γ, IL-21, and IL-17A was increased, while IL-10 was reduced, in the chronic colitis group compared to the control group, but the levels of all these factors were restored after NAM treatment. Then, 16S rRNA sequencing of the large intestinal content was performed, and analysis of alpha diversity and beta diversity showed that the richness of the gut microbiota was decreased in the DSS group compared to the control group and restored after NAM treatment. In addition, NAM modulated specific bacteria, including Odoribacter, Flexispira, and Bifidobacterium, in the NAM+chronic colitis group. Phylogenetic Investigation of Communities by Reconstruction of Unobserved States (PICRUSt) analysis indicated that NAM treatment restored disruptions in the functions of the gut microbiota (replication and repair, cell motility) in mice with DSS-induced colitis. Furthermore, NAM also restored the reduction in valeric acid in mice with DSS-induced chronic colitis. Our results suggest that NAM treatment could alleviate DSS-induced chronic colitis in mice by inhibiting inflammation and regulating the composition and function of gut microbiota.