From my research, it’s normal for people to fart as they sleep. Farting overnight or when sleeping can be due to the relaxation and increased pressure on the anal sphincter muscle. These muscles tend to be more relaxed when people sleep and can increase your farting as gas increases in the large intestines triggering unintended gas release.
Farting as you sleep can be due to swallowing air when chewing, increased stomach gas or acids, and the production or release of certain gases such as methane and hydrogen by the gut bacteria. Consuming flatulogenic foods or drinks like soda, beans, onions, cabbage, prunes, carbonated drinks, pastries, broccoli, and those high in fiber can increase nighttime farting. Smoking, taking some antibiotics, swallowing food fast and medical conditions such as IBS, Crohn’s disease, Ulcerative Colitis, Stomach cancer, and Celiac disease can contribute to overnight farting.