Chronic social isolation (SI) stress, which became more prevalent during the COVID-19 pandemic, contributes to abnormal behavior, including mood changes and cognitive impairment. Known as a functional nutrient, betaine has potent antioxidant and anti-inflammatory properties in vivo. However, whether betaine can alleviate the abnormal behavior induced by chronic SI in mice remains unknown. In this study, we investigated the efficacy of betaine in the treatment of behavioral changes and its underlying mechanism. Three-week-old male mice were randomly housed for 8 weeks in either group housing (GH) or SI. The animals were divided into normal saline-treated GH, normal saline-treated SI, and betaine-treated SI groups in the sixth week. The cognitive and depression-like behavior was determined in the eighth week. We found that long-term betaine administration improved cognitive behavior in SI mice but failed to prevent depression-like behavior. Moreover, long-term betaine administration inhibited hippocampal microglia over-activation and polarized microglia toward the M2 phenotype, which effectively inhibited the expression of inflammatory factors in SI mice. Finally, the protective effect of betaine treatment in SI mice might not be due to altered activity of the hypothalamic–pituitary–adrenal axis. Collectively, our findings reveal that betaine can improve SI-induced cognitive impairment, thus providing an alternative natural source for the prevention of memory loss caused by SI or loneliness.