Myocardial fibrosis is an important manifestation of diabetic cardiomyopathy. This study investigated the potential mechanism of diabetic myocardial fibrosis. Male C57BL/6J and db/db mice aged 8 weeks were randomly divided into the diabetic (DB) and control groups. At 20 weeks, the mouse heart was harvested and subjected to hematoxylin-eosin staining (HE) and Masson staining to investigate the degree of fibrosis. The expressions of transforming growth factor-beta 1 (TGF-β1), collagen-III, B-cell lymphoma-2 (Bcl2), Bcl2-associated X protein (Bax), cleaved gasdermin D (GSDMD), cysteinyl aspartate specific proteinase-1 (caspase-1), apoptosis-associated speck-like protein containing a CARD (ASC), and nucleotide-binding oligomerization domain (NOD)-like receptor 3 (NLRP3) were measured by western blotting. Immunohistochemistry and TdT-mediated dUTP nick end labeling (TUNEL) staining were performed to analyze the development of apoptosis and pyroptosis. A significant increase in body weight and blood glucose in the DB group was observed. Myocardial pathological injury, fibrosis, apoptosis, and pyroptosis were more obvious and serious in the DB group. The expression of anti-apoptotic Bcl2 significantly decreased, while the expression levels of pro-apoptotic Bax, caspase-3, and pyroptosis-related proteins, such as cleaved GSDMD, and caspase-1 in the DB group were significantly increased. Pyroptosis and apoptosis were probably the main mechanisms that caused myocardial fibrosis in mice with diabetes.