The artificial mucus layer, such as hydrogels, used to repair the damaged intestinal barrier, is a promising treatment for inflammatory bowel disease (IBD). However, the currently reported hydrogel-based artificial barriers are administered via rectal injection, causing unnecessary discomfort to patients. Herein, we report an oral hydrogel precursor solution based on thiol-modified hyaluronic acid (HASH). Owing to the reactive oxygen species (ROS)–responsive gelling behavior, our precursor solution formed an artificial mucus coating over the inflamed regions of the intestines, blocking microbial invasion and reducing abnormally activated immune responses. Notably, HASH also modulated the gut microbiota, including increasing the diversity and enhancing the abundance of short-chain fatty acid–associated bacteria, which play a key role in gut homeostasis. We believe that the ROS-responsive artificial mucus layer is a promising strategy for the oral treatment of IBD.