Background: Both obesity and the presence of collagenolytic bacterial strains (Enterococcus faecalis) can increase the risk of anastomotic leak. The aim of this study was to determine whether mice chronically fed a high-fat Western-type diet (WD) develop anastomotic leak in association with altered microbiota, and whether this can be mitigated by a short course of standard chow diet (SD; low fat/high fibre) before surgery. Methods: Male C57BL/6 mice were assigned to either SD or an obesogenic WD for 6 weeks followed by preoperative antibiotics and colonic anastomosis. Microbiota were analysed longitudinally after operation and correlated with healing using an established anastomotic healing score. In reiterative experiments, mice fed a WD for 6 weeks were exposed to a SD for 2, 4 and 6 days before colonic surgery, and anastomotic healing and colonic microbiota analysed. Results: Compared with SD-fed mice, WD-fed mice demonstrated an increased risk of anastomotic leak, with a bloom in the abundance of Enterococcus in lumen and expelled stool (65–90 per cent for WD versus 4–15 per cent for SD; P = 0·010 for lumen, P = 0·013 for stool). Microbiota of SD-fed mice, but not those fed WD, were restored to their preoperative composition after surgery. Anastomotic healing was significantly improved when WD-fed mice were exposed to a SD diet for 2 days before antibiotics and surgery (P < 0·001). Conclusion: The adverse effects of chronic feeding of a WD on the microbiota and anastomotic healing can be prevented by a short course of SD in mice. Surgical relevance Worldwide, enhanced recovery programmes have developed into standards of care that reduce major complications after surgery, such as surgical-site infections and anastomotic leak. A complementary effort termed prehabilitation includes preoperative approaches such as smoking cessation, exercise and dietary modification. This study investigated whether a short course of dietary prehabilitation in the form of a low-fat/high-fibre composition can reverse the adverse effect of a high-fat Western-type diet on anastomotic healing in mice. Intake of a Western-type diet had a major adverse effect on both the intestinal microbiome and anastomotic healing following colonic anastomosis in mice. This could be reversed when mice received a low-fat/high-fibre diet before operation. Taken together, these data suggest that dietary modifications before major surgery can improve surgical outcomes via their effects on the intestinal microbiome.