Introduction: Heart failure (HF) is a major cause of cardiovascular morbidity. Efficient and accurate prediction of incident heart failure episodes may enable preventive efforts. Methods: Using raw 12-lead ECG waveforms, we developed a convolutional neural network to predict HF admissions (Electrocardiogram to Heart Failure, “ECG2HF”). ECG2HF was developed in 91,573 individuals in Massachusetts General Hospital (MGH), and validated in three independent test sets: MGH, Brigham and Women’s Hospital (BWH), and the UK Biobank, among individuals without a prior HF episode. HF events were identified using a validated natural language processing model (MGH and BWH), and inpatient diagnosis codes (UK Biobank). Discrimination was quantified using time-dependent average precision (AP) and area under the receiver operating characteristic curve (AUROC). Among individuals with available data, we compared ECG2HF to the Pooled Cohort Equations for Heart Failure (PCE-HF). Results: The test sets comprised MGH (15,695 individuals, age 55±17, 51% women), BWH (52,124 individuals, age 55±17, 59% women), and UK Biobank (42,135 individuals, age 65±8, 52% women). ECG2HF consistently discriminated incident HF events (MGH 10-year AP: 0.17 [95% CI 0.15-0.20], 10-year AUROC 0.88 [0.86-0.89]; BWH: 0.15 [0.14-0.17], 0.87 [0.85-0.88]; UK Biobank 3-year AP 0.036 [0.024-0.057], 3-year AUROC 0.73 [0.68-0.77]). ECG2HF risk consistently stratified longitudinal HF incidence. Compared to PCE-HF, discrimination using ECG2HF was favorable in MGH/BWH (improvement in AP 0.07 [-0.11-0.14], improvement in AUROC 0.13 [0.088-0.18]), and UK Biobank (improvement in AP 0.016 [0.0060-0.033], improvement in AUROC -0.0093 [-0.062-0.044]). Conclusions: Artificial intelligence-enabled analysis of the 12-lead ECG may facilitate identification of individuals at risk for HF to enable early treatment to reduce HF-related morbidity.