Multiple sclerosis (MS) is a common central nervous system (CNS) autoimmune disease, and diets and nutrients are emerging as critical contributing factors. However, a comprehensive understanding of their impacts and the underlying mechanisms involved is lacking. Harnessing state-of-the-art nutritional geometry analytical methods, we first revealed that globally, increased carbohydrate supply was associated with increased MS disease burden, while fat supply had an opposite effect. Furthermore, in a preclinical MS mouse model, experimental autoimmune encephalomyelitis (EAE), we found that an isocaloric diet high in carbohydrate aggravated EAE, while a diet enriched in fat was fully protective. This was reflected by reduced neuroinflammation and skewing towards anti-inflammatory phenotypes, which involved transcriptomic, epigenetic and immunometabolic changes. We showcased that manipulating diets is a potentially efficient and cost-effective approach to prevent and/or ameliorate EAE. This exhibits translational potentials for intervention/prevention of MS and possibly other autoimmune diseases.