Irritable bowel syndrome (IBS) is a prevalent functional gastrointestinal disease characterized by chronic visceral pain with a complex etiology and challenging treatment. Although accumulating evidence supports the involvement of central nervous system sensitization in the development of visceral pain, the precise molecular mechanisms remain incompletely understood. In this study, we highlight the critical regulatory role of lysine-specific demethylase 6B (KDM6B) in the anterior cingulate cortex (ACC) in chronic visceral pain. To simulate clinical IBS conditions, we utilized the neonatal maternal deprivation (NMD) mouse model. Our results demonstrated that NMD induced chronic visceral pain and anxiety-like behaviors in mice. Notably, the protein expression level of KDM6B significantly increased in the ACC of NMD mice, leading to a reduction in the expression level of H32K7me3. Immunofluorescence staining revealed that KDM6B primarily co-localizes with neurons in the ACC, with minimal presence in microglia and astrocytes. Injecting GSK-J4 (a KDM6B-specific inhibitor) into ACC of NMD mice, resulted in a significant alleviation in chronic visceral pain and anxiety-like behaviors, as well as a remarkable reduction in NR2B expression level. ChIP assay further indicated that KDM6B regulates NR2B expression by influencing the demethylation of H3K27me3. In summary, our findings underscore the critical role of KDM6B in regulating chronic visceral pain and anxiety-like behaviors in NMD mice. These insights provide a basis for further understanding the molecular pathways involved in IBS and may pave the way for targeted therapeutic interventions.