Epigenetic changes are caused by biochemical regulators of gene expression that can be transferred across generations or through cell division. Epigenetic modifications can arise from a variety of environmental exposures including undernutrition, obesity, physical activity, stress and toxins. Transient epigenetic changes across the entire genome can influence metabolic outcomes and might or might not be heritable. These modifications direct and maintain the cell-type specific gene expression state. Transient epigenetic changes can be driven by DNA methylation and histone modification in response to environmental stressors. A detailed understanding of the epigenetic signatures of insulin resistance and the adaptive response to exercise might identify new therapeutic targets that can be further developed to improve insulin sensitivity and prevent obesity. This Review focuses on the current understanding of mechanisms by which lifestyle factors affect the epigenetic landscape in type 2 diabetes mellitus and obesity. Evidence from the past few years about the potential mechanisms by which diet and exercise affect the epigenome over several generations is discussed.