The ketogenic diet has been widely used in the treatment of various nervous system and metabolic-related diseases. Our previous research found that a ketogenic diet exerts a protective effect and promotes functional recovery after spinal cord injury. However, the mechanism of action is still unclear. In this study, different dietary feeding methods were used, and myelin expression and gene level changes were detected among different groups. We established 15 RNA-seq cDNA libraries from among 4 different groups. First, KEGG pathway enrichment of upregulated differentially expressed genes and gene set enrichment analysis of the ketogenic diet and normal diet groups indicated that a ketogenic diet significantly improved the steroid anabolic pathway in rats with spinal cord injury. Through cluster analysis, protein-protein interaction analysis and visualization of iPath metabolic pathways, it was determined that Sqle, Sc5d, Cyp51, Dhcr24, Msmo1, Hsd17b7, and Fdft1 expression changed significantly. Second, through weighted gene co-expression network analysis showed that rats fed a ketogenic diet showed a significant reduction in the expression of genes involved in immune-related pathways, including those associated with immunity and infectious diseases. A ketogenic diet may improve the immune microenvironment and myelin growth in rats with spinal cord injury through reprogramming of steroid metabolism.