Sanhan Huashi granules (SHG) demonstrated therapeutic effects against coronavirus disease 2019 (COVID-19) in observational studies. In order to compare the effectiveness and safety of SHG and nirmatrelvir-ritonavir in treating adults with mild-to-moderate COVID-19, we conducted a randomized, active-controlled, open-label, multi-center trial conducted between February and July in 2023. The patients were randomized in a 1:1 ratio to the SHG group and the nirmatrelvir-ritonavir group. A total of 400 participants were randomized, among which 200 participants ultimately received SHG and 198 received nirmatrelvir-ritonavir. The primary outcome was time to sustained clinical recovery through day 28. SHG significantly shortened the median time to sustained clinical recovery compared to nirmatrelvir-ritonavir (6.0 (95% CI, 5.0 to 6.0) vs. 8.0 (95% CI, 6.0 to 9.0) d; P = 0.001), particularly for individual symptoms including fever, sore throat, cough and fatigue. No participants in either group died and incidence of severe COVID-19 showed no difference between two groups. Participants who received nirmatrelvir-ritonavir demonstrated a higher rate of virus clearance on day 5 compared to those received SHG (46.4% (95% CI, 39.1 to 53.7) vs. 65.6% (95% CI, 58.3 to 72.4); P < 0.001). Most adverse events were mild in both groups. In summary, SHG was superior to nirmatrelvir-ritonavir in shortening the time to sustained clinical recovery in participants with mild-to-moderate COVID-19, despite a lower virus clearance rate observed after 5 d of treatment (Chinese Clinical Trial Registry Identifier: ChiCTR2300067872).