Background: There are few studies on using rivaroxaban and low molecular heparin (LMWH) to prevent venous thromboembolism (VTE) in hospitalized cancer patients. Objective: We conducted a retrospective study to evaluate the efficacy and safety of rivaroxaban versus LMWH for the primary prevention of VTE in inpatient cancer patients. Methods: Information on patients was collected through 6-month follow-up and medical record inquiries. Clinical outcomes included VTE, total bleeding, thrombosis, major bleeding, minor bleeding, all-cause death, and a composite endpoint of bleeding, thrombosis, and death. Results: A total of 602 hospitalized cancer patients were included in this study. During 6 months of follow-up, there were 26 VTE events (8.6%), 42 total bleeding events (7.0%), 62 all-cause deaths (10.3%), and 140 composite endpoints (23.3%). After adjusting for various confounding factors, there were no significant differences between the rivaroxaban and LMWH for VTE events (OR = 0.851, 95% CI [0.387-1.872], P=0.688), total bleeding (OR = 1.690, 95% CI [0.768-3.719], P = 0.192], thrombosis events (OR = 0.919, 95% CI [0.520-1.624], P = 0.772], major bleeding (OR = 0.276, 95% CI [0.037-2.059], P = 0.209), all-cause death (OR = 0.994, 95% CI [0.492-2.009], P = 0.987), and composite endpoints (OR = 0.994, 95% CI [0.492-2.009], P = 0.987), while minor bleeding (OR = 3.661 95% CI [1.000-7.083], P = 0.050) was significantly higher in the rivaroxaban than in the LMWH. Conclusions and Relevance: In thromboprophylaxis in inpatient cancer patients, rivaroxaban has a similar rate of VTE and bleeding events as LMWH. Our results may provide a reference for the clinical use of rivaroxaban to prevent VTE in hospitalized cancer patients.