Constipation is a common gastrointestinal disorder with a significant impact on quality of life. Diets play an important role as a modifiable lifestyle factor that can affect the onset and progression of constipation. This review examines the effects and mechanisms of multiple dietary patterns, including a high-fat diet, Mediterranean diet, fiber-rich diet, and plant-based diet, on constipation, microecological agents (probiotics, prebiotics, and synbiotics), and bioactive compounds (polysaccharides and polyphenols). In summary, the Mediterranean and plant-based diets can reduce the risk of constipation with favorable changes in gut microbiota, increase contents of short-chain fatty acids (SCFAs), and reduce the inflammatory markers. A fiber-rich diet increases stool bulk, retains water due to its high water-binding capacity, and serves as a substrate for gut microbiota. Additionally, microbiota can ferment fiber-rich diet to produce gases and SCFAs, which create an osmotic load and accelerate intestinal transit. Conversely, a high-fat diet correlates with an increased incidence of constipation with unfavorable changes in gut microbiota and reduces 5-hydroxytryptamine (5-HT) availability and mucin secretion. Meanwhile, probiotics, prebiotics, and synbiotics relieve constipation by restoring the imbalance of gut microbiota and increasing the contents of SCFAs and neurotransmitters. Also, polyphenols alleviate constipation by enhancing intestinal barrier, balancing neurotransmitters, and suppressing gut inflammation. Polysaccharides upregulate the expression of gastrointestinal transport proteins and genes (such as transient receptor potential vanilloid 1 [TRPV1], aquaporin 3 [AQP3], vasoactive intestinal peptide receptor 1 [VIPR1]) to maintain intestinal peristalsis. Furthermore, given the inter-individual in metabolic responses to dietary intake, we propose a framework for developing personalized diets for individuals with constipation, tailored to their specific compositions of gut microbiota.