Immune checkpoint inhibitors (ICIs) markedly promote the survival outcome of advanced melanoma and non-small cell lung cancer (NSCLC). Clinically, favorable ICI treatment efficacy is noticed only in a smaller proportion of patients. Heparan sulfate proteoglycan 2 (HSPG2) frequently mutates in both tumors. Herein, we aim to investigate the immunotherapeutic and immunological roles of HSPG2 mutations in melanoma and NSCLC. A total of 631 melanoma samples and 109 NSCLC samples with both somatic mutational profiles and clinical immunotherapy data were curated. In addition, by using The Cancer Genome Atlas data, genomic and immunological traits behind HSPG2 mutations were elucidated. Melanoma patients with HSPG2 mutations had a markedly extended ICI outcome than other patients. An association between HSPG2 mutations and the improved outcome was further confirmed in NSCLC. In addition, an elevated ICI response rate was presented in HSPG2-mutated NSCLC patients (81.8% vs. 29.7%, p = 0.002). Subsequent analyses revealed that HSPG2-mutated patients had a favorable abundance of response immunocytes, an inferior abundance of suppression immunocytes, enhanced mutational burden, and interferon response-relevant signaling pathways. We uncovered that HSPG2 mutations were predictive of a better ICI response and associated with preferable immunogenicity, which may be considered as a genomic determinant to customize biotherapy strategies.