Non-alcoholic fatty liver disease (NAFLD) poses a global health challenge. While pyroptosis is implicated in various diseases, its specific involvement in NAFLD remains unclear. Thus, our study aims to elucidate the role and mechanisms of pyroptosis in NAFLD. Utilizing data from the Gene Expression Omnibus (GEO) database, we analyzed the expression levels of pyroptosis-related genes (PRGs) in NAFLD and normal tissues using the R data package. We investigated protein interactions, correlations, and functional enrichment of these genes. Key genes were identified employing multiple machine learning techniques. Immunoinfiltration analyses were conducted to discern differences in immune cell populations between NAFLD patients and controls. Key gene expression was validated using a cell model. Analysis of GEO datasets, comprising 206 NAFLD samples and 10 controls, revealed two key PRGs (TIRAP, and GSDMD). Combining these genes yielded an area under the curve (AUC) of 0.996 for diagnosing NAFLD. In an external dataset, the AUC for the two key genes was 0.825. Nomogram, decision curve, and calibration curve analyses further validated their diagnostic efficacy. These genes were implicated in multiple pathways associated with NAFLD progression. Immunoinfiltration analysis showed significantly lower numbers of various immune cell types in NAFLD patient samples compared to controls. Single sample gene set enrichment analysis (ssGSEA) was employed to assess the immune microenvironment. Finally, the expression of the two key genes was validated in cell NAFLD model using qRT-PCR. We developed a prognostic model for NAFLD based on two PRGs, demonstrating robust predictive efficacy. Our findings enhance the understanding of pyroptosis in NAFLD and suggest potential avenues for therapeutic exploration.