The aspartate to alanine transaminase (AST/ALT) ratio indicates oxidative stress and inflammatory reactions related to the occurrence of diabetic retinopathy (DR). Currently, there are no reports on the correlation between AST/ALT ratio and DR. Hence, this study aimed to explore the relationship between AST/ALT ratio and DR. This cross-sectional study utilized data from the Metabolic Management Center of the First People's Hospital in City. In total, 1365 patients with type 2 diabetes mellitus (T2DM) participated in the study, including 244 patients with DR and 1121 patients without DR. We collected the results of fundus photography, liver function, and other research data and grouped them according to tertiles of AST/ALT ratios. DR prevalence was the highest in the group with the highest AST/ALT ratio (22.12%, P = .004). Both univariate (OR = 2.25, 95% CI: 1.51-3.34, P < .001) and multivariable logistic regression analyses (adjusted for confounding factors) showed that the risk of DR increased by 36% when the AST/ALT ratio increased by 1 standard deviation (SD) (OR = 1.36, 95% CI: 1.16-1.59, P < .001), and 29.3% was mediated by the duration of diabetes. A sensitivity analysis confirmed the stability of the results. This study showed that an increase in AST/ALT ratio is an independent risk factor for DR.