The objective of this study was to investigate the seroprevalence of syphilis and its possible influencing factors in patients with mental illness. A total of 24,414 patients with mental illness from 2019 to 2021 were included. Serum syphilis antibody test results and available demographic data were collected. Chi-square test and regression analysis were used to analyze the data. The seroprevalence of syphilis was 0.59% (95% CI 0.49-0.69%) in patients with mental illness in the study area. There were significant differences in the seroprevalence of syphilis in age, marital status, occupation, urban region, and mental disease classification. The seroprevalence of syphilis increased with age (p < 0.01). The seroprevalence of syphilis was higher in patients with "Nonorganic sleep disorders" and "Reaction to severe stress, and adjustment disorders". Adjusted logistic regression analysis showed that the seroprevalence of syphilis in patients with mental illness was associated with age, region, and psychiatric classification. Older age group was a risk factor for syphilis seropositivity. Compared with schizophrenia, "bipolar affective disorder" (OR = 1.707, 95% CI: 1.017-2.864, p = 0.043) and "severe stress response and adjustment disorders"(R = 4.912, 95% CI: 1.138-21.204, p = 0.033) were risk factors for syphilis antibody positivity. The patients with "nonorganic sleep disorders" and "reaction to severe stress, and adjustment disorders" had a high seroprevalence of syphilis. Age and psychosis types became the influencing factors of the positive rate of serum syphilis antibody in patients with mental illness.