Background: Acute kidney injury (AKI) is a common complication in hospitalized patients and a common cause for chronic kidney disease (CKD) and increased hospital cost and mortality. By timely detection of AKI and AKI progression, effective preventive or therapeutic measures could be offered. This study aims to develop and validate an electronic phenotype to identify patients with CKD and AKI. Methods: A database with electronic health records data from a retrospective study cohort of 84,352 hospitalized adults was created. This repository includes demographics, comorbidities, vital signs, laboratory values, medications, diagnoses and procedure codes for all index admission, 12 months prior and 12 months follow-up encounters. We developed algorithms to identify CKD and AKI based on the Kidney Disease: Improving Global Outcomes (KDIGO) criteria. To measure diagnostic performance of the algorithms, clinician experts performed clinical adjudication of AKI and CKD on 300 selected cases. Results: Among 149,136 encounters, identified CKD by medical history was 12% which increased to 16% using creatinine criteria. Among 130,081 encounters with sufficient data for AKI phenotyping 21% had AKI. The comparison of CKD phenotyping algorithm to manual chart review yielded PPV of 0.87, NPV of 0.99, sensitivity of 0.99, and specificity of 0.89. The comparison of AKI phenotyping algorithm to manual chart review yielded PPV of 0.99, NPV of 0.95 , sensitivity 0.98, and specificity 0.98. Conclusions: We developed phenotyping algorithms that yielded very good performance in identification of patients with CKD and AKI in validation cohort. This tool may be useful in identifying patients with kidney disease in a large population, in assessing the quality and value of care in such patients.