Crohn’s disease and ulcerative colitis, collectively known as IBD, are chronic inflammatory disorders of the gastrointestinal tract. Although the aetiopathogenesis of IBD is largely unknown, it is widely thought that diet has a crucial role in the development and progression of IBD. Indeed, epidemiological and genetic association studies have identified a number of promising dietary and genetic risk factors for IBD. These preliminary studies have led to major interest in investigating the complex interaction between diet, host genetics, the gut microbiota and immune function in the pathogenesis of IBD. In this Review, we discuss the recent epidemiological, gene–environment interaction, microbiome and animal studies that have explored the relationship between diet and the risk of IBD. In addition, we highlight the limitations of these prior studies, in part by explaining their contradictory findings, and review future directions.