Berberine, which is a potential antidepressant, exhibits definite efficiency in modulating the gut microbiota. Depressive behaviors in mice induced using chronic unpredictable mild stress (CUMS) stimulation were evaluated by behavioral experiments. The markers of neurons and synapses were measured using immunohistochemical staining. An enzyme-linked immunosorbent assay was adopted to analyze serum inflammatory cytokines levels and neurotransmitters were evaluated by LC-MS/MS. Untargeted metabolomics of tryptophan metabolism was further performed using LC-MS/MS. The target enzymes of berberine involved in tryptophan metabolism were assayed using AutoDock and GRMACS softwares. Then, antibiotics was utilized to induce intestinal flora disturbance. Berberine improved the depressive behaviors of mice in a microbiota-dependent manner. Increased neurons and synaptic plasticity were observed following berberine treatment. Meanwhile, berberine decreased serum levels of TNF-α, IL-1β, and IL-4 and increased levels of IL-10. Moreover, berberine induced retraction of the abnormal neurotransmitters and metabolomics assays revealed that berberine promoted tryptophan biotransformation into serotonin and inhibited the kynurenine metabolism pathway, which was attributed to the potential agonist of tryptophan 5-hydroxylase 1 (TPH1) and inhibitor of indoleamine 2,3-dioxygenase 1 (IDO1). In conclusion, berberine improves depressive symptoms in CUMS-stimulated mice by targeting both TPH1 and IDO1, which are involved in tryptophan metabolism.