Background Preterm birth affects a child's development and health. Vitamin D may influence the health of neonates. Our objective was to evaluate vitamin D levels and contributing factors in preterm and full-term newborns in Wuxi, China. Methods A retrospective study was performed on neonates at the Affiliated Women's Hospital of Jiangnan University from May 2020 to May 2022. The neonates were classified into three categories: very preterm (< 32(+ 0) weeks, n = 167), preterm (32(+ 0)-36(+ 6) weeks, n = 454), and full-term (>= 37(+ 0) weeks, n = 192). Serum concentrations of 25-hydroxyvitamin D were assessed. We employed the Kruskal-Wallis test, Mann-Whitney U tests, or chi-squared tests to compare categorical variables. The binary logistic regression study aimed to identify potential risk variables. Results The median blood 25-hydroxyvitamin D concentration was 35.9 nmol/L, with roughly 82.7% categorized as vitamin D deficiency. However, the frequency of vitamin D insufficiency did not vary significantly across the three groups. Serum 25-hydroxyvitamin D levels at birth in full-term, preterm, and very preterm children exhibit substantial differences when mother body mass index exceeds 30 kg/m(2) (P < 0.001). Newborn vitamin D levels shown considerable variations among three groups categorized by maternal body mass index, maternal age, and season of birth. In terms of the preterm birth phenotypes, deficiency was significantly associated with fetal growth restriction, fetal distress, and neonatal infections. No significant differences in vitamin D levels were observed among the three groups for mode of conception, number of gestations, or maternal gestational age. Furthermore, the deficiency rates of vitamin D were not markedly different among full-term, preterm, and very preterm newborns. Conclusion Vitamin D levels in newborns were correlated with maternal obesity, maternal age, season of birth, preeclampsia, fetal growth restriction, neonatal infection, and fetal distress. At delivery, full-term infants born to women with a BMI exceeding 30 kg/m(2) or those delivered in winter exhibit significantly elevated levels of 25-hydroxyvitamin D compared to preterm and very preterm newborns.