BACKGROUND: Systematic identification of patients allows researchers and clinicians to test new models of care delivery. EHR phenotypes-structured algorithms based on clinical indicators from EHRs-can aid in such identification. OBJECTIVE: To develop EHR phenotypes to identify decedents with stage 4 solid-tumor cancer or stage 4-5 chronic kidney disease (CKD). DESIGN: We developed two EHR phenotypes. Each phenotype included International Classification of Diseases (ICD)-9 and ICD-10 codes. We used natural language processing (NLP) to further specify stage 4 cancer, and lab values for CKD. SUBJECTS: Decedents with cancer or CKD who had been admitted to an academic medical center in the last 6 months of life and died August 26, 2017-December 31, 2017. MAIN MEASURE: We calculated positive predictive values (PPV), false discovery rates (FDR), false negative rates (FNR), and sensitivity. Phenotypes were validated by a comparison with manual chart review. We also compared the EHR phenotype results to those admitted to the oncology and nephrology inpatient services. KEY RESULTS: The EHR phenotypes identified 271 decedents with cancer, of whom 186 had stage 4 disease; of 192 decedents with CKD, 89 had stage 4-5 disease. The EHR phenotype for stage 4 cancer had a PPV of 68.6%, FDR of 31.4%, FNR of 0.5%, and 99.5% sensitivity. The EHR phenotype for stage 4-5 CKD had a PPV of 46.4%, FDR of 53.7%, FNR of 0.0%, and 100% sensitivity. CONCLUSIONS: EHR phenotypes efficiently identified patients who died with late-stage cancer or CKD. Future EHR phenotypes can prioritize specificity over sensitivity, and incorporate stratification of high-and low-palliative care need. EHR phenotypes are a promising method for identifying patients for research and clinical purposes, including equitable distribution of specialty palliative care.