BACKGROUND Insomnia seriously affects people's health and quality of life. Short-term use of Western drugs may also be harmful. Traditional Chinese medicine has been widely used to treat diseases in world. Therefore, this paper aims to study the therapeutic effect of berberine based on the insomnious rat model. MATERIAL AND METHODS The insomnia rat model was established by intragastric administration of caffeine and parachlorophenylalanine (PCPA). Berberine and diazepam were used to treat the established insomnia rats. Then, the pathological changes of insomnia rats were detected. In addition, transcriptome sequencing and data analysis were carried out using rat hippocampus. The expression of key genes was verified by quantitative polymerase chain reaction and western blot. RESULTS After 7 days of intragastric administration of berberine, the body weight, memory, and sleep quality of insomnia rats were significantly improved. The key roles of Erbb4, Erbb2, Ar, and Grin2a in berberine treatment were identified. Through the analysis of biological functions and signaling pathways, berberine was shown to play a salutary role through nervous system development and ErbB signaling pathway. Gene-set enrichment analysis (GSEA) results showed that berberine treatment affected more metabolic pathways. Compared with diazepam, berberine can play a faster role, and also improve the overall health level of insomnia rats. CONCLUSIONS These results suggest that berberine can alleviate insomnia in rats through a neuroprotective effect and improved metabolic level. Berberine has great potential in treatment of insomnia and might have better clinical significance.