SARS-CoV-2 nucleocapsid (N) protein plays the essential roles in key steps of the viral life cycle, thus representing a top drug target. Functionality of N protein including liquid–liquid phase separation (LLPS) depends on its interaction with nucleic acids. Only the variants with N proteins functional in binding nucleic acids might survive and spread in evolution and indeed, the residues critical for binding nucleic acids are highly conserved. Hydroxychloroquine (HCQ) was shown to prevent the transmission in a large-scale clinical study in Singapore but so far, no specific SARS-CoV-2 protein was experimentally identified to be targeted by HCQ. Here by NMR, we unambiguously decode that HCQ specifically binds NTD and CTD of N protein with Kd of 112.1 and 57.1 μM, respectively to inhibit their interaction with nucleic acid, as well as to disrupt LLPS. Most importantly, HCQ-binding residues are identical in SARS-CoV-2 variants and therefore HCQ is likely effective to different variants. The results not only provide a structural basis for the anti-SARS-CoV-2 activity of HCQ, but also renders HCQ to be the first known drug capable of targeting LLPS. Furthermore, the unique structure of the HCQ-CTD complex suggests a promising strategy for design of better anti-SARS-CoV-2 drugs from HCQ.