Objective To explore the effects of virtual reality technology-based preoperative visit on the improvement of sleep quality of cardiac surgery patients. Methods A total of 88 patients undergoing cardiac surgery were selected as the study subjects, and they were randomly assigned to a control group (conventional preoperative visit) and an intervention group (preoperative visit with virtual reality technology), with 44 cases in each group by using the random number table method. Sleep quality and anxiety were compared between the two groups before the intervention and within 48 hours of transfer from the care unit to the cardiac surgery ward.Results There were 3 cases lost in the control group and 5 cases lost in the intervention group.Within 48 hours of transfer to the cardiac surgery ward, the intervention group had significantly higher scores of Richards-Campbell Sleep Questionnaire (RCSQ) and lower scores of the Self-rating Anxiety Scale (SAS) than those of the control group (both P<0.05). Conclusion Preoperative visits based on virtual reality technology can improve sleep quality and reduce anxiety in cardiac surgery patients.