Metabolic-associated steatohepatitis (MASH) and ulcerative colitis (UC) exhibit a complex interconnection with immune dysfunction, dysbiosis of the gut microbiota, and activation of inflammatory pathways. This study aims to identify and validate critical butyrate metabolism-related shared genes between both UC and MASH. Clinical information and gene expression profiles were sourced from the Gene Expression Omnibus (GEO) database. Shared butyrate metabolism-related differentially expressed genes (sBM-DEGs) between UC and MASH were identified via various bioinformatics methods. Functional enrichment analysis was performed, and UC patients were categorized into subtypes using the consensus clustering algorithm based on sBM-DEGs. Key genes within sBM-DEGs were screened through Random Forest, Support Vector Machines-Recursive Feature Elimination, and Light Gradient Boosting. The diagnostic efficacy of these genes was evaluated using receiver operating characteristic (ROC) analysis on independent datasets. Additionally, the expression levels of characteristic genes were validated across multiple independent datasets and human specimens. Forty-nine shared DEGs between UC and MASH were identified, with enrichment analysis highlighting significant involvement in immune, inflammatory, and metabolic pathways. The intersection of butyrate metabolism-related genes with these DEGs produced 10 sBM-DEGs. These genes facilitated the identification of molecular subtypes of UC patients using an unsupervised clustering approach. ANXA5, CD44, and SLC16A1 were pinpointed as hub genes through machine learning algorithms and feature importance rankings. ROC analysis confirmed their diagnostic efficacy in UC and MASH across various datasets. Additionally, the expression levels of these three hub genes showed significant correlations with immune cells. These findings were validated across independent datasets and human specimens, corroborating the bioinformatics analysis results. Integrated bioinformatics identified three significant biomarkers, ANXA5, CD44, and SLC16A1, as DEGs linked to butyrate metabolism. These findings offer new insights into the role of butyrate metabolism in the pathogenesis of UC and MASH, suggesting its potential as a valuable diagnostic biomarker.