Ventricular arrhythmias are among the most severe complications of heart disease and can result in sudden cardiac death. Patients at risk currently receive implantable defibrillators that deliver electrical shocks to terminate arrhythmias on demand. However, strong electrical shocks can damage the heart and cause severe pain. Therefore, we have tested optogenetic defibrillation using expression of the light-sensitive channel channelrhodopsin-2 (ChR2) in cardiac tissue. Epicardial illumination effectively terminated ventricular arrhythmias in hearts from transgenic mice and from WT mice after adeno-associated virus–based gene transfer of ChR2. We also explored optogenetic defibrillation for human hearts, taking advantage of a recently developed, clinically validated in silico approach for simulating infarct-related ventricular tachycardia (VT). Our analysis revealed that illumination with red light effectively terminates VT in diseased, ChR2-expressing human hearts. Mechanistically, we determined that the observed VT termination is due to ChR2-mediated transmural depolarization of the myocardium, which causes a block of voltage-dependent Na+ channels throughout the myocardial wall and interrupts wavefront propagation into illuminated tissue. Thus, our results demonstrate that optogenetic defibrillation is highly effective in the mouse heart and could potentially be translated into humans to achieve nondamaging and pain-free termination of ventricular arrhythmia.