Diabetic cardiomyopathy (DCM) is an important complication resulting in heart failure and death of diabetic patients. However, there is no effective drug for treatments. This study investigated the effect of D‐pinitol (DP) on cardiac injury using diabetic mice and glycosylation injury of cardiomyocytes and its molecular mechanisms. We established the streptozotocin‐induced SAMR1 and SAMP8 mice and DP (150 mg/kg/day) intragastrically and advanced glycation end‐products (AGEs)‐induced H9C2 cells. H9C2 cells were transfected with optineurin (OPTN) siRNA and overexpression plasmids. The metabolic disorder indices, cardiac dysfunction, histopathology, immunofluorescence, western blot, and immunoprecipitation were investigated. Our results showed that DP reduced the blood glucose and AGEs, and increased the expression of heart OPTN in diabetic mice and H9C2 cells, thereby inhibiting the endoplasmic reticulum stress (GRP78, CHOP) and glycophagy (STBD1, GABARAPL1), and alleviating the myocardial apoptosis and fibrosis of DCM. The expression of filamin A as an interaction protein of OPTN downregulated by AGEs decreased OPTN abundance. Moreover, OPTN siRNA increased the expression of GRP78, CHOP, STBD1, and GABARAPL1 and inhibited the expression of GAA via GSK3β phosphorylation and FoxO1. DP may be helpful to treat the onset of DCM. Targeting OPTN with DP could be translated into clinical application in the fighting against DCM.