We aimed to investigate the preventive effect of vitamin D2 on COVID-19 and the improvement of symptoms after COVID-19 infection. The study recruited 228 health care workers who tested negative PCR or antigen for COVID-19. Subjects were randomly allocated to vitamin D2 or non-intervention at a ratio 1:1. Subjects recorded PCR or antigen tests and the symptoms of COVID-19 twice a week during the follow-up visit. The concentration of serum 25-hydroxyvitamin D (25(OH)D), C-reaction protein (CRP), complement component C1q and inflammatory cytokines were measured. The rates of COVID-19 infection were 50.5% in the vitamin D2 group and 52.4% in the non-intervention group (P = 0.785). There was no difference in the COVID-19 symptoms between the two groups. The mean 25(OH)D level significantly increased from 14.1 to 31.1 ng/mL after administration (P < 0.001). The difference between the two groups was not significant for the concentrations of CRP, C1q and inflammatory cytokines on the thirtieth day of the trial. According to the second level of vitamin D, there was a 14.3% difference in positive infection rates between the vitamin D adequate (> 30 ng/mL) and deficient groups (< 20 ng/mL). Adequate vitamin D had a tendency to prevent COVID-19.Trial registration: ClinicalTrials.gov NCT05673980, dated: 12/2022.