Mental illness is associated with large costs to individuals and society. Education improves various health outcomes but little work has been done on mental illness. To obtain unbiased estimates of the effect of education on mental health, we rely on a rich longitudinal dataset that contains health information from childhood to adulthood and thus allow us to control for fixed effects in mental health. We measure two health outcomes: malaise score and depression and estimate the extensive and intensive margins of education on mental health using various estimators. For all estimators, accounting for the endogeneity of education augments its protecting effect on mental health. We find that the effect of education is greater at mid-level of qualifications, for women and for individuals at greater risk of mental illness. The effects of education are observed at all ages, additionally education also reduces the transition to depression. These results suggest substantial returns to education in term of improved mental health.